gpt4 book ai didi

linux - 无法从linux命令发送邮件

转载 作者:行者123 更新时间:2023-12-04 18:50:08 30 4
gpt4 key购买 nike

我想从 linux 命令发送电子邮件。我在ubuntu ssmtp中安装,然后在/etc/ssmtp/ssmtp.conf中配置:

root=mymail@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
FromLineOverride=YES
AuthUser=mymail@gmail.com
AuthPass=xxxxxxxxx
UseTLS=YES
UseSTARTTLS=YES

然后我尝试这样发送电子邮件:
ssmtp receiver_mail@gmail.com < msg.txt

但我得到了这个错误:
ssmtp: Authorization failed (535 5.7.8  https://support.google.com/mail/?p=BadCredentials t187sm393455wmt.25 - gsmtp)

然后我尝试使用 sendmail 命令:
 echo -n 'Subject: test\n\nTesting ssmtp' | sendmail -v receiver_mail@gmail.com

但我得到了同样的错误:
[<-] 220 smtp.gmail.com ESMTP a22sm418259wmd.20 - gsmtp
[->] EHLO omar-X550LC
[<-] 250 SMTPUTF8
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
[->] EHLO omar-X550LC
[<-] 250 SMTPUTF8
[->] AUTH LOGIN
[<-] 334 VXNlcm5hbWU6
[->] b21hci5rYWxsZWwzQGdtYWlsLmNvbQ==
[<-] 334 UGFzc3dvcmQ6
[<-] 535 5.7.8 https://support.google.com/mail/?p=BadCredentials a22sm418259wmd.20 - gsmtp
sendmail: Authorization failed (535 5.7.8 https://support.google.com/mail/?p=BadCredentials a22sm418259wmd.20 - gsmtp)

似乎 ssmtp 配置中有问题或缺失。有什么建议可以解决这个问题吗?

最佳答案

您是否尝试阅读错误消息中包含的支持链接?除了您提供错误密码的可能性之外,它还提供了一些其他可能性:

  • Use an App Password: If you use 2-Step Verification, try signing in with an App Password.
  • Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.
  • Make sure your mail app isn't set to check for new email too frequently. If your mail app checks for new messages more than once every 10 minutes, the app’s access to your account could be blocked.

关于linux - 无法从linux命令发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60445395/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com