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 = "myemail@gmail.com";
$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...
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.
I had similar problems with GMail when using it through CodeIgniter
For me, changing the host option worked:
$mail->Host = "ssl://smtp.googlemail.com";
Set $mail->SMTPDebug = 1;
It will give you more info about this error.
Most likely you will get
"Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP". To fix this remove ";" from ;extension=php_openssl.dll line in php.ini.
PS
I also like XAMPP :)))
$host = "ssl://smtp.gmail.com";
$port = "465"
I changed from SSL to ssl. It works.
According to this post here, Google may not be offering this service any more:
http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/