我手动运行日志监视(没有cron作业)。我使用nullmailer使用ISP的SMTP服务器从服务器发送电子邮件。我可以从命令行发送测试邮件,没问题。但是logwatch使用的是一个坏的"From“地址,导致我的ISP拒绝电子邮件,而且我找不到要更改的设置。
在我的logwatch配置文件中,我有MailFrom = me@gmail.com。logwatch生成的电子邮件的第一行如下所示:
root@myserverhostname.gmail.com
me@timewarnercable.com
Received: (nullmailer pid 5939 invoked by uid 0);
Sun, 25 Sep 2016 15:25:02 -0000
To: me@timewarnercable.com
From: root@gmail.com
Subject: Logwatch for myserverhostname (Linux)注意,文件第一行中的地址已插入myserverhostname。不幸的是,这似乎是真正使用的地址。From: line上的域是正确的,并且可以工作,只是它将我的用户名更改为root。文件匹配的To:行和第2行。
注意: From: address并不完全是logwatch配置文件中显示的。我指定了MailFrom = me@gmail.com,它显示在From as root@gmail.com中。似乎日志监视的配置文件设置在某个地方被重写。
如何阻止日志监视将myserverhostname插入from地址并将我的名称更改为root?
编辑: logwatch.conf的相关部分
# Default person to mail reports to. Can be a local account or a
# complete email address. Variable Output should be set to mail, or
# --output mail should be passed on command line to enable mail feature.
MailTo = me@timewarnercable.com
# WHen using option --multiemail, it is possible to specify a different
# email recipient per host processed. For example, to send the report
# for hostname host1 to user@example.com, use:
#Mailto_host1 = user@example.com
# Multiple recipients can be specified by separating them with a space.
# Default person to mail reports from. Can be a local account or a
# complete email address.
MailFrom = me@gmail.com来自mail.log的错误
Sep 25 11:15:52 myserverhostname nullmailer[10724]: smtp: Failed: 550 5.1.0 <root@myserverhostname.gmail.com> sender rejected : invalid sender domain当logwatch生成电子邮件时,它没有使用我在配置文件的MailFrom行中提供的值。
在MailFrom上,我提供了me@gmail.com,但它在电子邮件的第一行使用了root@myserverhostname.gmail.com,在电子邮件的From:行中使用了root@gmail.com。我需要它至少在第一行中说me@gmail.com。如果我手动编辑电子邮件并替换该行,它就会发送得很好。
发布于 2016-09-26 01:13:23
非常感谢海因内马的有益建议。他向我指出了第二个配置文件,该文件可以修改以解决问题。
结果发现,这不是logwatch或nullmailer的问题,而是sendmail本身的问题。是sendmail忽略了logwatch配置文件中的输入,并插入了它自己的from地址值。
幸运的是,/user/share/logwatch/dist.conf/logwatch.conf文件有一行
mailer = "/usr/sbin/sendmail -t"我能够通过将这个改为读来强制正确的地址。
mailer = "/usr/sbin/sendmail -t -f me@gmail.com"https://askubuntu.com/questions/829466
复制相似问题