Unable to send mail with localhost / xampp

Failed to connect to the mail server on the port "mail.google.com" 587, check the settings "SMTP" and "smtp_port" in php.ini or use ini_set()

I configured my php.ini xppp file and sendmail.ini to use my Gmail account to send email from my PHP script. I am using xampp. after changing the [mail function] function of my php.ini it looks like this (I just deleted the outlined contours for simplicity)

 [mail function] SMTP = mail.google.com smtp_port = 587 mail.add_x_header = Off 

and my sendmail.ini file looks like this:

 [sendmail] smtp_server=mail.google.com smtp_port=587 smtp_ssl=auto error_logfile=error.log auth_username=babar+gmail.com auth_password=********** 

So what did I miss? Why am I getting this error?

+3
php xampp gmail
Jul 17 '13 at 12:19
source share
2 answers

You are using the wrong SMTP settings for gmail. The correct ones are:

In php.ini

 [mail function] ;SMTP = localhost ;sendmail_from = me@example.com sendmail_path = "c:\sendmail\sendmail.exe -t -i" 

In sendmail.ini

 [sendmail] smtp_server=smtp.gmail.com smtp_port=587 smtp_ssl=tls auth_username=me@example.com auth_password=********** 

Note. If you enable 2-step verification , you need to create a special password for the application.

+2
Jul 17 '13 at 12:38
source share

set smtp_ssl = auto as smtp_ssl = true

since google smtp server requires ssl

0
Jul 17 '13 at 12:32
source share



All Articles