Gmail settings Google Gmail does not allow sending emails with PHPMailer

I created an account in Gmail (because the previous problem was giving me the same problem) so that my app can send emails using Google's SMT server.

I am using PHPMailer library and am asking to show log errors.

I always get a message like this. This is slightly different, sometimes shorter and sometimes longer depending on my configuration.

2015-08-01 05:07:01 CLIENT -> SERVER: EHLO www.lavile.com 
2015-08-01 05:07:01 CLIENT -> SERVER: AUTH LOGIN 
2015-08-01 05:07:01 CLIENT -> SERVER: Y29udGF0by5sYXZpbGVAZ21haWwuY29t 
2015-08-01 05:07:01 CLIENT -> SERVER: WXlhdUgxMnM= 2015-08-01 05:07:01  SMTP ERROR: Password command failed: 534-5.7.9 Please log in with your web browser and then try again. Learn more at 534 5.7.9 https://support.google.com/mail/answer/78754 b16sm3352387qga.48 - gsmtp 
2015-08-01 05:07:01 SMTP Error: Could not authenticate. 
2015-08-01 05:07:01 CLIENT -> SERVER: QUIT 
2015-08-01 05:07:01 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting string(82) "SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting"

      

This is my script

    $mail->Username = "myusername@gmail.com";
    $mail->Password = "mypassword";

    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 465; // or 587
    $mail->IsHTML(true);
    $mail->SetFrom($mail->Username, 'Contato Lavile');
    $mail->addAddress($mail->Username, "Contato Lavile");
    $mail->Subject = 'Novo contato no site Lavile';
    $mail->Body = $text;
    $mail->IsHTML(true);
    $mail->AltBody = $text;

      

GMAIL also sends me automatic emails warning me that a new login attempt has been blocked. I even changed some settings in my gmail to make it work but it all failed

Any ideal? Do you know what can happen?

+3


source to share


4 answers


I would recommend to actually read the error message:

... 534-5.7.9 Log in to your web browser and try again. More details at 534 5.7.9 https://support.google.com/mail/answer/78754 b16sm3352387qga.48 - gsmtp



As you read this site, you will find something about customer support that only provide less secure authentication methods. Your client is one of them, so follow the link to find out how to enable support for these apps in gmail.

+4


source


You can send email without your own smtp server: 1) get recipient mx hostname from dns 2) send email to port 25



0


source


Not to say this is necessarily what happened to the theme opener, but I had the exact same error today. And the reason I got this was because I created a new email and you first need to login to Gmail once through your browser before you can use smtp.

After logging into the Gmail web client through a browser and going through the initial flow, I was able to send it through the smtp endpoint.

0


source


$mail->Host = "smtp.gmail.com";

should look something like this:

$mail->Host = "mail.yourdomain.com";//replace your domain name

      

-2


source







All Articles