Send Email Using Gmail as my SMTP from XAMPP (PHP)

Share

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 doesnt 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 (xamppphpphp.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:xamppsendmailsendmail.exe” -t”

Note: I did install my xampp at D:xampp



1. Edit your sendmail.ini (xamppsendmailsendmail.ini)

Comment the “Mercury”and “A free mail service example” contents as shown below:

# Mercury
#account Mercury
#host localhost
#from postmaster@localhost
#auth off

# A freemail service example
#account Hotmail
#tls on
#tls_certcheck off
#host smtp.live.com
#from [exampleuser]@hotmail.com
#auth on
#user [exampleuser]@hotmail.com
#password [examplepassword]



2. Add the account through which you want to send your mails. In my example I have configured the Gmail account as shown below:

account Gmail
tls on
tls_certcheck off
host smtp.gmail.com
from [your_gmail_username]@gmail.com
auth on
user [your_gmail_username]@gmail.com
password [your_gmail_password]port 587



3. Set the default account to Gmail as shown below:

account default : Gmail

Many thanks to this link . 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.

Share

Comments

comments

Tags: , , , , , , , , ,

3 Responses to “Send Email Using Gmail as my SMTP from XAMPP (PHP)”

  1. aliimmam says:

    sendmail_path = “”D:xamppsendmailsendmail.exe” -t”

  2. Hina says:

    Hello. And Bye.

Leave a Reply