Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to send mail through Google SMTP with PHPMailer

Tags:

smtp

phpmailer

I'm trying to send out mail using Google's SMTP in combination with PHPMailer, but I can't get it to work. This is my code:

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

First I do not fully understand what should be filled in as 'SMTPSecure', some say 'ssl', other say 'tls'. Next for 'Port' I could enter '465' or '587'. But none of the combinations work... Note that I'm using a regular Gmail account and not Google Apps. In my Gmail account I've enabled 'POP access'.

The error I get is: "Must issue a STARTTLS command first". Which means SSL failed, but don't know why...

like image 750
bart Avatar asked Dec 08 '22 07:12

bart


1 Answers

Ok, the problem was the version of PHPMailer. I updated to PHPMailer version 5 and everything worked great. I was using phpMailer version 1.02.

like image 191
bart Avatar answered Dec 26 '22 17:12

bart