Failed to send mail via Google SMTP using PHPMailer

I am trying to send mail using Google SMTP in combination with PHPMailer, but I cannot get it to work. This is my code:

$mail->IsSMTP(); $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Username = " myemail@gmail.com "; $mail->Password = "**********"; $mail->Port = "465"; 

At first I don’t quite understand what should be filled in as "SMTPSecure", some say " ssl ", others say " tls ". Further for "Port" I can enter "465" or "587". But none of the combinations work ... Please note that I am using a regular Gmail account and not Google Apps. In my Gmail account, I have enabled "access to POP".

I get the error: " Must issue a STARTTLS command first ". This means that SSL failed, but I don’t know why ...

+4
source share
5 answers

Well, the problem was in the PHPMailer version. I updated the version of PHPMailer version 5 and everything worked fine. I used phpMailer version 1.02.

+6
source

I had similar problems with GMail when using it through CodeIgniter

For me, the host parameter has changed:

 $mail->Host = "ssl://smtp.googlemail.com"; 
+5
source

Set $ ​​mail-> SMTPDebug = 1; This will give you more information about this error. Most likely you will get "Ssl socket transfer could not be found - you forgot to enable it when setting up PHP." To fix this, remove the ";" from; extension = php_openssl.dll in php.ini.

PS I also like XAMPP :)))

+3
source

$ host = "ssl: //smtp.gmail.com"; $ port = "465"

I changed from SSL to ssl. It is working.

+1
source
0
source

All Articles