I have been trying to send email using PHP script and XAMPP Lite. The PHP script itself is not a biggies but the default XAMPP configuration doesn’t allow me to send out the email. My objective is to use Gmail as my SMTP (rather than localhost). After some digging and try and error.. here is my solution.
- Edit your php.ini (xampp\php\php.ini). Search for [mail function] and change these parameters accordingly.
- SMTP = smtp.gmail.com
- smtp_port = 587
- sendmail_from = [your_gmail_username]@gmail.com
- Note: this gmail account will be used to send the email
- sendmail_path = “\”D:\xampp\sendmail\sendmail.exe\” -t”
- Note: I did install my xampp at D:\xampp
- Edit your sendmail.ini (xampp\sendmail\sendmail.ini)
- 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
Many thanks to Pallavi. His original post point me to the right direction. The only missing piece is port number in sendmail.ini where gmail no longer use port 25 as smtp port but 587. Hope this help.