后缀/清理不好琐碎重写

我使用监控程序munin,在服务器出现问题时通过电子邮件通知我。 它发送电子邮件为munin

通常,当这样的邮件在互联网上发送时,当调用postfix/cleanup时,它会要求进行重写 ,这realdomain.tld附加到不完整的发件人地址。

From: munin@thehostname没有,因为我的Postfix SMTP客户端然后尝试发送包含From: munin@thehostname标题,这是谷歌不喜欢的电子邮件:

 Jul 22 10:00:15 thehostname postfix/pickup[3167]: 979BD1E447E: uid=110 from=<munin@thehostname> Jul 22 10:00:15 thehostname postfix/cleanup[9609]: 979BD1E447E: message-id=<[email protected]> Jul 22 10:00:15 thehostname postfix/qmgr[3276]: 979BD1E447E: from=<munin@thehostname>, size=454, nrcpt=1 (queue active) Jul 22 10:00:16 thehostname postfix/smtp[9611]: 979BD1E447E: to=<[email protected]>, relay=ASPMX.L.GOOGLE.COM[173.194.67.27]:25, delay=0.49, delays=0.07/0/0.12/0.3, dsn=5.7.1, status=bounced (host ASPMX.L.GOOGLE.COM[173.194.67.27] said: 550-5.7.1 [9.8.7.6 1] Our system has detected an unusual rate of 550-5.7.1 unsolicited mail originating from your IP address. To protect our 550-5.7.1 users from spam, mail sent from your IP address has been blocked. 550-5.7.1 Please visit http://www.google.com/mail/help/bulk_mail.html to review 550 5.7.1 our Bulk Email Senders Guidelines. x12si10440172wia.27 - gsmtp (in reply to end of DATA command)) Jul 22 10:00:16 thehostname postfix/cleanup[9609]: 372F91E4483: message-id=<[email protected]> Jul 22 10:00:16 thehostname postfix/qmgr[3276]: 372F91E4483: from=<>, size=3167, nrcpt=1 (queue active) Jul 22 10:00:16 thehostname postfix/bounce[9614]: 979BD1E447E: sender non-delivery notification: 372F91E4483 Jul 22 10:00:16 thehostname postfix/qmgr[3276]: 979BD1E447E: removed Jul 22 10:00:16 thehostname postfix/local[9617]: 372F91E4483: to=<munin@thehostname>, relay=local, delay=0.13, delays=0.05/0.01/0/0.06, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION") Jul 22 10:00:16 thehostname postfix/qmgr[3276]: 372F91E4483: removed 

我不知道为什么这个微不足道的改写不能像munin用户所期望的那样工作,为什么在互联网上发送电子邮件之前没有得到正确的发件人地址。

其他程序,如fail2ban成功发送电子邮件,并被重写为[email protected]

这是我的configuration有趣的部分:

 myhostname = realdomain.tld mydomain = thehostname mydestination = localhost.localdomain, localhost, $mydomain, $myhostname myorigin = $myhostname mynetworks = relayhost = 

我认为在重写过程中肯定有一些我不明白的东西!

编辑

我发现这篇文章谈论后缀地址重写。

用户重写为user @ $ myorigin

该function由boolean append_at_myorigin参数控制(默认:是)。 目的是在$ myorigin的每台机器上获得一致的用户处理。

我没有改变append_at_myorigin参数,它应该设置为“是”。 $ myorigin被设置为realdomain.tld,但重写错误并select$ mydomain。

从第一个日志行

 Jul 22 10:00:15 thehostname postfix/pickup[3167]: 979BD1E447E: uid=110 from=<munin@thehostname> 

我们可以得出这样的结论:munin守护进程将发件人设置为不仅仅是munin munin@thehostname (没有域部分)作为您的假设。


作为一个certificate ,我通过sendmail CLI发送邮件

 $ mail [email protected] Subject: test test 

以上命令将在queue_directory / maildrop中添加队列。 运行postcat命令查看队列内容

 $ sudo postcat -q 5A1AD347819 *** ENVELOPE RECORDS maildrop/5A1AD347819 *** message_arrival_time: Thu Oct 9 23:02:43 2014 named_attribute: rewrite_context=local sender_fullname: User sender: myuser recipient: [email protected] *** MESSAGE CONTENTS maildrop/5A1AD347819 *** To: [email protected] Subject: test test *** HEADER EXTRACTED maildrop/5A1AD347819 *** *** MESSAGE FILE END maildrop/5A1AD347819 *** 

在这种情况下,发件人只是没有域名的myuser 。 这里inputmaillog发送。

 Oct 9 23:05:11 web postfix/pickup[79682]: 9808834784D: uid=1010 from=<zagalo> Oct 9 23:05:11 web postfix/cleanup[79684]: 9808834784D: message-id=<[email protected]> Oct 9 23:05:11 web postfix/qmgr[79683]: 9808834784D: from=<[email protected]>, size=318, nrcpt=1 (queue active) 

所以,微不足道的重写在你的情况下是无关紧要的。 你的电子邮件有正确的发件人地址,所以没有改写。

解?

  • 告诉munin更改发件人地址(我的Google快速search没有提供有用的结果)。
  • 另外,设置smtp_generic_maps为您的munin提供重写。

     /etc/postfix/main.cf: smtp_generic_maps = hash:/etc/postfix/generic /etc/postfix/generic: munin@thehostname [email protected]