Sending email in PHP using XAMPP Lite 1.7.3 on Windows
I have been unsuccessfully trying to send an email in PHP on XAMPP Lite version 1.7.3 on Windows since yesterday. However today after going through some other blogs and a little bit of my own research I was able to successfully send an email to my gmail account 🙂
Here are the steps I followed:
- Change in php.ini file. The file path is “C:\xampplite\php” (if your XAMPP Lite folder is in C drive).
- Search for sendmail_path in your php.ini file and remove the semi colon before it. Then set it to sendmail_path = “C:\xampplite\sendmail\sendmail.exe -t” (Make sure to test this path on your system first and correct it if necessary)
- Changes in sendmail.ini file. The file path is “C:\xampplite\sendmail” (if your XAMPP Lite folder is in C drive).
- Comment the “Mercury” and “A free mail service example” contents as shown below:
# A freemail service example
2. Add the account through which you want to send your mails. In my example I have configured the Gmail account as shown below:
3. Set the default account to Gmail as shown below:
account default : Gmail
- Now the required configuration changes have been done. We need to restart the Apache Server to reflect the changes in php.ini file.
- I have written a sample program below to check if mail is being sent.
$body=”This is my demo email sent using PHP on XAMPP Lite version 1.7.3″;
echo “Mail sent successfully!”;
echo “Mail not sent!”;
- On executing the above program I was able to successfully send a mail to any receiver address from PHP using XAMPP Lite 1.7.3 on Windows.
- Hope this blog helps you in case you have encountered a similar problem as I did. Please feel free to comment if this blog was useful to you.