您好,我已使用 msmtp 和 sendmail 在 Ubuntu 20.04 服务器上设置了无人值守升级。我想将无人值守升级的结果发送到我的电子邮件。但是电子邮件不是由无人值守升级发送的!
我已将我的电子邮件地址添加到无人值守升级设置中:
Unattended-Upgrade::Mail "[email protected]";
我的/etc/mail.rc
样子是:
set sendmail="/usr/bin/msmtp -t"
我的 msmtp 配置(/etc/msmtprc
)如下所示:
defaults
port 587
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account [email protected]
host smtp.mail.yahoo.com
from [email protected]
auth on
logfile /var/log/msmtp
user [email protected]
password abc
account default: [email protected]
aliases /etc/aliases
具有以下权限:
ls -l /etc/msmtprc
-rw-r----- 1 root msmtp 2741 Dec 15 12:23 /etc/msmtprc
我的用户目录中有相同的配置(/home/me/.msmtprc
):
ls -l /home/me/.msmtprc
-rw------- 1 me msmtp 2725 Dec 15 09:51 /home/me/.msmtprc
现在我能够成功发送电子邮件:
echo "content" | mail -s "test email" [email protected]
上述命令在 /var/log/msmtp 中的日志为:
Dec 15 13:04:31 host=smtp.mail.yahoo.com tls=on auth=on [email protected] [email protected] [email protected] mailsize=153 smtpstatus=250 smtpmsg='250 OK , completed' exitcode=EX_OK
但是当我手动运行无人值守升级时,sudo /usr/bin/unattended-upgrade -d
我得到:
bla bla bla
bla bla bla
bla bla bla
Sending mail to [email protected]
sendmail: the server sent an empty reply
sendmail: could not send mail (account default from /etc/msmtprc)
mail returned: 76
上面命令的日志是:
Dec 15 13:23:03 host=smtp.mail.yahoo.com tls=on auth=on [email protected] [email protected] [email protected] errormsg='the server sent an empty reply' exitcode=EX_PROTOCOL