How to send email from XAMPP

Default configuration of XAMPP do not allow to send emails through localhost. Here is the configuration for XAMPP to send email using a gmail account.

First you need to upgrade sendmail to the latest version.

  1. go to and download
  2. backup files in xampp/sendmail/ directory.
  3. delete all files in xampp/sendmail/ directory.
  4. copy the downloaded zip file to xampp/sendmail/ directory and extract the file

Then open the php.ini file (xampp/php/php.ini) and search for [mail function]

Modify the following parameters accordingly.

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header = Off

Note: Modify sendmail_path parameter to your sendmail directory if you have installed xampp on an another directory.

Open the sendmail.ini (xampp/sendmail/sendmail.ini) and set following parameters accordingly. Comment all other settings.

Replace auth_username, auth_password, force_sender parameters with your gmail account details.

Once you have done the modifications you can test the settings using a test php email such as following;

$subject=”Hi There!!”;
$body=”This is a demo email sent using PHP on XAMPP″;
if (mail($to,$subject,$body)){
 echo “Mail sent successfully!”;
 echo “Mail not sent!”;

Enjoyed this article? Share with friends

  • Jacky

    Nice! It working perfectly. Thanks!!


Subscribe to our email feed and never miss a post

Join Us