Google Gmail SMTP 设置不允许我使用 PHPMailer 发送电子邮件 [英] Google Gmail SMTP settings not allowing me to send emails with PHPMailer

查看:146
本文介绍了Google Gmail SMTP 设置不允许我使用 PHPMailer 发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Gmail 上创建了一个帐户(因为前一个帐户给了我同样的问题),以便我的应用程序可以使用 google smtp 服务器发送电子邮件.

I created an account on Gmail (becase the previous one was giving me the same problem) so that my application could send emails using google smtp server.

我正在使用 PHPMailer 库并要求它显示任何日志错误.

I'm using the PHPMailer library and asked it to show any log errors.

我总是收到与此类似的消息.它略有不同,有时短有时长,取决于我的配置

I always get a message similar to this. It vary a little, sometimes it is 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"

这是我的剧本

    $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 会自动向我发送电子邮件,提醒我新的登录尝试被阻止.我什至更改了 Gmail 上的一些设置以使其正常工作,但一切都失败了

Also GMAIL is sending automatic emails to myself alerting me that a new login attempt was blocked. I even changed some settings on my gmail to make it work but everything failed

有什么想法吗?你知道会发生什么吗?

Any idead? Do you know what could be happening?

推荐答案

我建议实际阅读错误消息:

I would recommend to actually read the error message:

... 534-5.7.9 请使用您的网络浏览器登录,然后重试.如需了解详情,请访问 534 5.7.9 https://support.google.com/mail/answer/78754 b16sm3352387qga.48 - gsmtp

... 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

阅读本网站时,您会发现有关支持客户端的内容,这些内容仅提供不太安全的授权方法.您的客户就是其中之一,因此请点击链接了解如何启用对这些应用程序的支持在 Gmail 中.

When reading this site you will find something about supporting client which provide only less secure methods of authorization. Your client is one of these so follow the link to learn how to enable support for these application in gmail.

这篇关于Google Gmail SMTP 设置不允许我使用 PHPMailer 发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆