Gmail smtp SASL身份验证

时间:2018-01-14 20:04:18

标签: email smtp gmail postfix two-step-verification

我使用postfix通过gmail使用应用程序的密码发送电子邮件(激活了两步验证)。

每次我使用sendmail命令测试发送邮件时,都会收到此错误:

Action: delayed
Status: 4.7.14
Diagnostic-Code: X-Postfix; delivery temporarily suspended: SASL authentication
failed; server smtp.gmail.com said: 534-5.7.14
<https://accounts.google.com/signin/continue?...> Please log in via your web browser and?534-5.7.14 then try again.?534-5.7.14

这是我的后缀配置:

main.cf

myorigin = /etc/mailname
mydestination = mydomain.com, localhost.fr, localhost
relayhost = [smtp.gmail.com]:587

smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

/等/后缀/ SASL / sasl_passwd

[smtp.gmail.com]:587 admin@mydomain.com:application_password

这就是我使用sendmail的方式:

sendmail -v ...
From: admin@mydomain.com
Subject: Test
This is a test mail
.

有什么想法吗?谢谢!

2 个答案:

答案 0 :(得分:3)

对于发现遇到相同情况的任何人:

  1. 使用应用专用密码
  2. 您的帐户已启用2FA
  3. 看到“交付暂时暂停:SASL身份验证失败;服务器smtp.gmail.com [173.194.68.109]说:534-5.7.9请使用您的Web浏览器登录,然后在日志中重试

您可能需要访问https://accounts.google.com/DisplayUnlockCaptcha来“绕过”验证码,这将使您能够访问帐户并使一切正常。

答案 1 :(得分:2)

允许安全性较低的应用程序:如果您不使用两步验证,则可能需要允许安全性较低的应用程序访问您的帐户。

enter image description here