How to send email from xampp localhost
By Ujjwal Jha
May 29, 2015 16:39

For send email from xampp localhost you update these two files.

1.) sendmail.ini 

2.) php.ini 

 

Step.1 )

Open sendmail.ini file from your xammp sendmail folder and update its value to

smtp_server=smtp.gmail.com

error_logfile=error.log

debug_logfile=debug.log

auth_username=yourname@gmail.com

auth_password=yourgmailpassword

force_sender=yourname@gmail.com 

Note: Please check these lines are not commented(remove ';').

 

Step.2 )

Open xampp\php\php.ini file find sendmail_path and remove the comment on these lines.

"\"C:\xampp\sendmail\sendmail.exe\" -t".

 

Step.3 )

Restart your apache server.

Now you can send email from xampp localhost! enjoy :-)

 

Below the Php mail codes.

<?php

$to      = 'ravi.drupalchamp@gmail.com';

$subject = 'Testing Mail';

$message = 'Hello I am testing mail from localhost';

$headers = 'From: ujjwal.drupalchamp@gmail.com'; // here email id is only for show it works from sendmail.ini file

if(mail($to, $subject, $message, $headers)){

print "Mail working well";

}else{

print "Mail not working well";

}

?>

Also Please Turn On this gmail settings.
https://www.google.com/settings/security/lesssecureapps

Tags: How To

Add new comment

Contact Us