Authenticated PHP Mailer Sending using Gmail

Asked

Viewed 1,988 times

0

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 making that mistake:

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 the SMTP is the same?

  • Have some proxy or firewall on your network?

  • I am using my home network my computer has Microsoft’s own Windows Defender and is not using proxy...

  • What happens is that the site is on a server ( cloud ) and the emails are on another server. I’m trying to send it through the cloud server, but we tried to put the server address ( email ), but it was an error too. When we do not authenticate, the messages arrive in any other email, but in the emails of this server do not arrive. That’s why I want to use Gmail email for this, but it also gives SMTP error.

  • 1

    When I speak network I mean the network that the script ran, if the problem occurred in your server/ cloud is there in their firewall, you have to access the Cpanel (or equivalent and check if there are blocks), if you do not have access you will have to request with the support of the company

  • ah yes... I thought it was from here from home kkkkk ....entendi... I will take a look there....

  • 1

    For you to authenticate with google SMTP, you need XOAUTH2 and no more user password. There is an alternative that is to authorize "less secure applications", but the best would be to make the application work on the new standard.

Show 1 more comment

2 answers

1


0

Use

$mail -> SMTPSecure = "tls";

Sometimes door 587 only works with TLS with Gmail... happened to me.

Or

$mail->Port = 465;

For SSL

Besides having to release your email in your google account.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.