Thursday, October 2, 2014

PHP mail function using Gmail account in Windows XAMPP

1) When we test php mail code in  Windows XAMPP, we do  not have smtp server in localhost. Windows XAMPP has sendmail.exe, but do not have PHPmailer. The following setting will make mail function working in PHP in XAMPP.
2) For example, you install XAMPP in C:\xampp
in C:\xampp\sendmail\sendmail.ini:
in C:\xampp\php\php.ini:
[mail function]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
3) Replace  **** to your gmail account name and password.
Restart Apace in XAMPP.
4) testmail.php to test if mail function is working

    $message = "The mail message was sent with the following mail";
    $headers = "From:";
    mail("", "Testing", $message, $headers);
    echo "Test message is sent to<BR/>";
Change to your email account. You will receive an email. 
Video: PHP mail function using Gmail account in Windows XAMPP

5) PHPmailer is another option to send email in PHP. 

For Linux, refer to:

No comments:

Post a Comment