Sending PHP Mailer authenticated using Gmail

1

Colleagues.

I'm trying to send an email authenticated by PHPMailer using GMail this way:

include("PHPMailer/class.phpmailer.php");
require('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail -> SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = '[email protected]';
$mail->Password = 'senhadoemail';

but you're giving this error:

  

2016-04-30 18:24:54 SMTP ERROR: Failed to connect to server: (0)   2016-04-30 18:24:54 SMTP connect () failed.

Someone if SMTP is the same?

    
asked by anonymous 30.04.2016 / 20:27

2 answers

1

Almost sure that google is limiting access to email

Go to the page below and verify that less secure applications are released for the account in question

link

    
02.05.2016 / 16:13
1

Use

$mail -> SMTPSecure = "tls";

Sometimes port 587 only works with TLS with Gmail ... it happened to me.

Or

$mail->Port = 465;

For SSL

In addition to having to release your email in your google account.

    
30.09.2017 / 21:08