我的要求是:
我尝试过“通过 gmail 发送单行消息的最简单答案是使用 ssmtp”,以及几种变体,并不断得到:
笔记本电脑 sSMTP[19226]:授权失败(535 5.7.8 https://support.google.com/mail/?p=BadCredentials d13sm3920147qkj.27 - gsmtp)
谷歌设置:
对于我尝试的每个ssmtp.conf
设置,我之前已经完成了DisplayUnlockCaptcha :
$echo "Testing...1...2...3" | ssmtp myusername@gmail.com
Run Code Online (Sandbox Code Playgroud)
仅查看所述线程/etc/ssmtp/ssmtp.conf
,对于应如何设置尚未达成共识:
mailhub=smtp.gmail.com:587
VS 465UseTLS=YES
与UseSTARTTLS=Yes
(或两者?)hostname=localhost
与默认放置在那里的任何内容(在我的例子中,laptop
)有人可以提出解决这个问题的建议,并可能完整粘贴一个工作conf文件吗?
2017 年的一个帖子中有一个说法:
您无法使用普通密码使用外部应用程序,您必须访问https://security.google.com/settings/security/apppasswords
是这样吗?(我做不到)
还有哪些替代方案?
附:
使用以下 Google 设置:
IMAP enabled
Allow less secure apps is ON
Run Code Online (Sandbox Code Playgroud)
解决方案是设置应用程序密码:
注意: Google 设置的应用程序密码要求首先为您尝试为其配置 ssmtp 的帐户启用双因素身份验证。
/var/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
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
# Modified 06/27/2020:
# mailhub=mail
root=mysusername@gmail.com
AuthUser=mysusername@gmail.com
#AuthPass=[usual gmail pwd] # aint' gonna work
AuthPass=[pwd generated by https://myaccount.google.com/apppasswords]
#UseTLS=YES
#mailhub=smtp.gmail.com:465
UseSTARTTLS=Yes
mailhub=smtp.gmail.com:587
# Where will the mail seem to come from?
#rewriteDomain=
# The full hostname
hostname=laptop
# 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)
在终端上:
$echo "Testing...1...2...3" | ssmtp recipient@gmail.com
Run Code Online (Sandbox Code Playgroud)
附:
mutt
就像一个魅力一样。更新于 12/01/2022
使用msmtp
并且因为不太安全的应用程序被禁用
# content of /home/user/.msmtprc
# do: `$ chmod 600 /home/user/.msmtprc`
# gmail
account google-name@gmail.com
host smtp.gmail.com
port 587
tls on
tls_starttls on
auth on
user google-name
from google-name@gmail.com
# https://myaccount.google.com/apppasswords
password xxxxxxxxxxxxxxxx
# default account
account default : google-name@gmail.com
Run Code Online (Sandbox Code Playgroud)
$ chmod 600 /home/user/.msmtp
$ echo "Testing...1...2...3" | msmtp recipient.address@domain
这会发送至密件抄送,请在此处查找替代方案。
归档时间: |
|
查看次数: |
15213 次 |
最近记录: |