Failed to connect to mailserver at "mail.google.com" port 587, verify your "SMTP" and "smtp_port" setting in php.ini or use
I configured my xampp php.ini and sendmail.ini file to use my Gmail account for sending email from my PHP script. i am using xampp. after changing the [mail function] part of my php.ini looks like this (i have deleted commented outlines 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 have I missed? Why am I getting this error?
You are using wrong SMTP settings for gmail. The correct ones are:
[mail function] ;SMTP = localhost ;sendmail_from = [email protected] sendmail_path = "c:\sendmail\sendmail.exe -t -i"
[sendmail] smtp_server=smtp.gmail.com smtp_port=587 smtp_ssl=tls [email protected] auth_password=**********
Remeber: If you have enabled 2 step authentication, you have to create an application specific password.