0

EDIT

I uncomment sendmail_path and set it as sendmail_path = "sendmail -t -i". Now there is no error but no email received.

The port is 25, and tls://smtp.gmail.com is the server.

END EDIT

I need to send an email, locally, to an the admin, when a user request a new password. At the top of my API.php file, I have added the following ini_set() lines:

ini_set("SMTP","tls://smtp.gmail.com");

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","587");

// Please specify the return address to use
ini_set('sendmail_from', 'example@YourDomain.com');

And also, I've changed the php.ini file to the same values:

mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = tls://smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from ="admin@wampserver.invalid"

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =

The error I am having is:

Warning: mail(): Failed to connect to mailserver at "tls://smtp.gmail.com" port 587, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp64\www\dev\api.php on line 165

I used the scripts at line 165 but still the same. I have openssl enabled as echo phpinfo(); showed.

I changed the port to 25, with localhost as smtp, but still the same error.

The following didn't help me as it is giving me the same error message.

First Post

alim1990
  • 4,656
  • 12
  • 67
  • 130

0 Answers0