如何修复“发送邮件:授权失败 534 5.7.14”

Con*_*ect 67 email sendmail gmail ssmtp

我正在尝试在 ssh root 登录时创建电子邮件警报,因此我必须安装ssmtp邮件实用程序。

然后我配置ssmtp.conf文件如下:

# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
        #root=postmaster
        #Adding  email id to receive system information
root = rootuser@gmail.com
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
        #mailhub=mail

mailhub = smtp.gmail.com:587

AuthUser=dmymail@gmail.com
AuthPass=plaintext password
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
rewriteDomain=gmail.com

# The full hostname

hostname = mailserver
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
Run Code Online (Sandbox Code Playgroud)

以及以下重新定义:

# Format:       local_account:outgoing_address:mailhub
# Example: root:your_login@your.domain:mailhub.your.domain[:port]

root:rootuser@gmail.com:smtp.gmail.com:25
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

send-mail: Authorization failed (534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 ni5sm3908366pbc.83 - gsmtp)
Can't send mail: sendmail process failed with error code 1
Run Code Online (Sandbox Code Playgroud)

但它没有用。请帮我解决这个问题

小智 113

解决此问题可能需要多个步骤

  1. 采取前面提到的步骤。登录您的谷歌电子邮件帐户,然后转到此链接:https : //www.google.com/settings/security/lesssecureapps并将“访问不太安全的应用程序”设置为开启。测试您的问题是否已解决。如果它没有解决,因为它不适合我,请继续执行步骤 #2。

  2. 转至https://support.google.com/accounts/answer/6009563(标题为:“密码错误”)。此页面显示“在使用第三方应用程序登录 Google 时,您可能会看到“密码不正确”错误(又名 534-5.7.14)的原因有多种。在某些情况下,即使您正确输入了密码。” 此页面提供了 4 项尝试的建议。

对我来说,第一个建议有效:

  • 从您之前用于访问 Google 帐户的其他设备转到https://g.co/allowaccess并按照说明进行操作。
  • 尝试从被阻止的应用程序重新登录。

在第 2 步中给出的页面上还有另外三个建议,但我没有尝试它们,因为在转到编辑后的链接并按照说明进行操作后,一切都开始正常工作。

  • 选项 1. 为我工作 (9认同)
  • +1,选项 1 后跟 https://g.co/allowaccess 效果很好。 (8认同)

小智 18

这对我有用。

1) 登录您的 Gmail 帐户。

2) 转到https://www.google.com/settings/security/lesssecureapps并打开此功能。

3) 前往https://accounts.google.com/DisplayUnlockCaptcha并点击继续。

然后您可以从您的 Gmail 帐户验证您的附加电子邮件地址。

编辑:就我而言,它有助于编写 smtp.gmail.com 而不是 smtp.gmail.com:587。

  • #3 对我来说是缺失的部分! (2认同)

小智 5

要解决此问题,您需要:

1) 使用网络浏览器登录您的 Gmail 帐户。

2) 单击此链接以启用应用程序访问您的帐户:https : //accounts.google.com/b/0/DisplayUnlockCaptcha

3) 单击“继续”按钮完成该步骤。

4) 现在再次尝试从您的 PHP 脚本发送电子邮件。它应该工作。


mai*_*ilq 0

您是否点击了提供的链接并阅读了说明?这是修复方法。

我敢打赌您输入了错误的用户名或密码。

如果它们确实正确,请验证您是否使用相同的端口。上面您指定了 587,而下面您指定了 25。

UseTLS那么指定和可能就不行了UseSTARTTLS。在端口 587 上使用 UseTLS,在端口 25 上使用 UseSTARTTLS。

最后,您的主机名可能不是“邮件服务器”。使用 FQDN。