php - Google Gmail SMTP 设置不允许我使用 PHPMailer 发送电子邮件

标签 php codeigniter smtp gmail phpmailer

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

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

我总是收到类似这样的消息。它略有不同,有时更短,有时更长,具体取决于我的配置

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 上的一些设置以使其正常工作,但一切都失败了

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

最佳答案

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

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

阅读本网站时,您会发现一些有关支持客户端的内容,这些客户端仅提供不太安全的授权方法。你的客户就是其中之一所以follow the link了解如何在 gmail 中启用对这些应用程序的支持。

关于php - Google Gmail SMTP 设置不允许我使用 PHPMailer 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31758501/

相关文章:

php - 将 sql 查询转换为 php codeigniter

php - 在 codeigniter 中的不同用途

email - 用于在我的 Web 应用程序上发送电子邮件的 SMTP 服务

Python 不向多个地址发送电子邮件

wordpress - 如何在 Docker 容器中从 WordPress(联系表格)发送电子邮件?

php - 我应该使用静态方法和属性来检测语言和翻译文本吗?

php - 通过javascript重复元素

php - 这就是 AltoRouter GET POST 方法的工作原理吗?

php - 带有巨大表的嵌套 mysql 查询

php - 基于日期的年份报表查询