Send Email from localhost using XAMPP for Windows

I have search from the Internet on this problem, as a web developer you may face this problem, many solutions out there but this is the that work for me, so I decided to write it and share it.

To Send Email from your localhost computer with authentication required from mail server, please follow this simple steps, on my configuration my XAMPP is located on:



1. Modify sendmail.ini

The configuration file is located at C:\xampp\sendmail\sendmail.ini, and please have a look on 4 variables, they are :

  • smtp_server
  • smtp_port
  • auth_username
  • auth_password

Find them, and change the value, here is the example:


; smtp port (normally 25)


; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL




2. Modify your php.ini

Open your php.ini from XAMPP control panel or locate your self, its located on C:\xampp\apache\bin\php.ini,

and please search sendmail_path variable, and simple uncomment that line.

sendmail_path = “C:\xampp\sendmail\sendmail.exe -t”


That’s all. and lets do the testmail.

Here simple php script to test your localhost php.

$from_name = “Eka”;
$from_email = “”;
$headers = “From: $from_name <$from_email>”;
$body = “Hi, \nThis is a test mail from $from_name <$from_email>.”;
$subject = “Test mail from Eka”;
$to = “”;

if (mail($to, $subject, $body, $headers)) {
echo “success!”;
} else {
echo “fail…”;


Leave a Reply

Your email address will not be published. Required fields are marked *