使用 sSMTP 阻止系统电子邮件

使用 sSMTP 阻止系统电子邮件

我有一台具有动态 IP 的家庭服务器(运行 Ubuntu 20.04.3),并且想以电子邮件的形式接收发送给 root 的系统邮件。我已经设置了 sSMTP 以通过 Gmail 帐户发送电子邮件。手动发送电子邮件有效。由系统事件引起的自动触发的电子邮件不会到达。所以我想知道手动发送电子邮件和由系统事件引起的自动电子邮件事件之间的区别。

这是我的 sSMTP 配置。

$ cat /etc/sSMTP/sSMTP.conf
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
[email protected]

# 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=smtp.gmail.com:587

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

# The full hostname
hostname=myhostname

# Are users allowed to set their own From: address?
FromLineOverride=YES

# Use SSL/TLS before starting negotiation
TLS_CA_FILE=/etc/ssl/certs/ca-certificates.crt
UseTLS=Yes
UseSTARTTLS=Yes

[email protected]
AuthPass=gmailpass

发送电子邮件原则上有效。我使用以下命令均能正确接收电子邮件。

$ echo "Content" | mail -s "Subject" [email protected]
$ echo "Content" | mailx -s "Subject" [email protected]
$ echo -e "Subject: Subject\n\nContent" | ssmtp [email protected]

但是,如果我触发自动邮件发送给 root,情况就不同了。例如,我故意为 sudo 命令输入错误的密码。

$ sudo ls
[sudo] password for myuser: 
Sorry, try again.
[sudo] password for myuser: 
sudo: 1 incorrect password attempt

此问题会触发一封电子邮件至[电子邮件保护],但电子邮件没有到达。相反,我收到了一封电子邮件[电子邮件保护]出现以下错误信息。

554 交易失败由于政策限制而拒绝。有关解释,请访问https://web.de/email/senderguidelines?ip=209.85.221.44&c=hi

以下是标题:

Reporting-MTA: dns; googlemail.com
Received-From-MTA: dns; [email protected]
Arrival-Date: Wed, 25 Aug 2021 13:14:10 -0700 (PDT)
X-Original-Message-ID: <[email protected]>

Final-Recipient: rfc822; [email protected]
Action: failed
Status: 5.0.0
Remote-MTA: dns; mx-ha02.web.de. (212.227.17.8, the server for the domain web.de.)
Diagnostic-Code: smtp; 554-Transaction failed
 554-Reject due to policy restrictions.
 554 For explanation visit https://web.de/email/senderguidelines?ip=209.85.221.44&c=hi
Last-Attempt-Date: Wed, 25 Aug 2021 13:14:10 -0700 (PDT)

我如何才能找出自动电子邮件事件使用的底层命令?我如何才能将自动电子邮件事件更改为像手动电子邮件事件一样运行,以便我收到电子邮件[电子邮件保护]? 非常感谢您的建议!

相关内容