PHPMailer with GMail: SMTP Error

By : Abs

I am making use of PHPMailer to send mail through GMail. The code I use is straight from a tutorial and it works perfectly on my laptop. However, testing this on a Windows 2003 Server - it seems to always return an SMPT error:

SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.

Here is the settings I use in PHPMailer:

$mail = new PHPMailer();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // use ssl
$mail->Host = ""; // GMAIL's SMTP server
$mail->Port = 465; // SMTP port used by GMAIL server

Can I say with confidence that this isn't a port issue, since I am connecting to another server on port 465 and it is sending mail. If not, please explain.

How can I resolve this issue?

Thanks all for any help

By : Abs


To use PHPMailer with gmail, don't use SSL/465 (it's been deprecated since 1998), use TLS/587 as Noctrine suggests, and here's how:

include 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "tls://"; // GMAIL's SMTP server
$mail->Port = 587; // SMTP port used by GMAIL server

You should find that works.

By : Synchro

First thing notice off-hand: Gmail uses TLS. Don't know if having SSL instead of TLS will make much of a difference but SSL is the predecessor to TLS.

I recommend checking out also, its phpmailer customized for using gmail. PHPGMailer

By : Noctrine

This video can help you solving your question :)
By: admin

PHPMailer SMTP Error 550

My server and php mail() function sends email to the spam folder

How to use PHPmailer? Help me with its API

PHPMailer Lite & GMAIL SMTP: emails not sent to Yahoo Mail, how to debug?

PHP, PHPMailer: Can't get example code for PHPMailer to work

PHPMailer Works on WAMP but not on Production Server

sending email using gmail server [duplicate]

fsockopen returns 'bool(false)' from browser but 'resource(4) of type (stream)' from command line

PHP on GoDaddy Linux Shared trying to send through GMAIL SMTP

PHPMailer or SwiftMailer? [duplicate]

Problem with SMTP emails sent via PhpMailer: Helo Not Accepted