![postfix 反复发送电子邮件 - 消息可能会发送多次](https://linux22.com/image/763985/postfix%20%E5%8F%8D%E5%A4%8D%E5%8F%91%E9%80%81%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6%20-%20%E6%B6%88%E6%81%AF%E5%8F%AF%E8%83%BD%E4%BC%9A%E5%8F%91%E9%80%81%E5%A4%9A%E6%AC%A1.png)
我把新成员的两封电子邮件添加到了我们 Debian/postfix 机器上的邮件列表中(仅用于向我们的成员发送电子邮件)。他们抱怨从我们的机器上收到了数百封电子邮件,不幸的是这是真的,我发现了另外两个使用不同域的用户(我们总共有约 10,000 名成员,没有问题)。
这是我在 mail.log 中发现的内容:
1: Feb 23 06:25:24 m2 postfix/smtp[26117]: 38F5020EB4: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=71848, delays=71222/0.03/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
15: Feb 23 06:30:23 m2 postfix/smtp[26224]: 3595420E53: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=77167, delays=76542/0.04/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
53: Feb 23 06:50:24 m2 postfix/smtp[26943]: C02C420E63: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=76640, delays=76014/0.01/26/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
170: Feb 23 07:25:24 m2 postfix/smtp[27635]: A1F4C20E26: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=81552, delays=80927/0.02/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
244: Feb 23 07:45:23 m2 postfix/smtp[28025]: 38F5020EB4: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=76648, delays=76022/0.04/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
250: Feb 23 07:50:23 m2 postfix/smtp[28165]: 3595420E53: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=81967, delays=81342/0.01/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
306: Feb 23 08:10:24 m2 postfix/smtp[28558]: C02C420E63: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=81440, delays=80814/0.01/26/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
431: Feb 23 08:45:23 m2 postfix/smtp[29315]: A1F4C20E26: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=86352, delays=85726/0.02/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
467: Feb 23 09:05:23 m2 postfix/smtp[29745]: 38F5020EB4: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=81448, delays=80822/0.01/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
484: Feb 23 09:10:23 m2 postfix/smtp[29830]: 3595420E53: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=86768, delays=86142/0.01/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
553: Feb 23 09:30:24 m2 postfix/smtp[30267]: C02C420E63: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=86240, delays=85614/0.03/26/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
672: Feb 23 10:05:25 m2 postfix/smtp[30949]: A1F4C20E26: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=91154, delays=90527/0.02/26/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
731: Feb 23 10:25:24 m2 postfix/smtp[31385]: 38F5020EB4: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=86248, delays=85622/0.01/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
746: Feb 23 10:30:24 m2 postfix/smtp[31493]: 3595420E53: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=91568, delays=90943/0.02/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
817: Feb 23 10:50:24 m2 postfix/smtp[31933]: C02C420E63: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=91040, delays=90413/0.03/25/601, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
927: Feb 23 11:25:24 m2 postfix/smtp[32608]: A1F4C20E26: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=95953, delays=95327/0.01/26/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
997: Feb 23 11:45:23 m2 postfix/smtp[533]: 38F5020EB4: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=91048, delays=90422/0.02/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
1009: Feb 23 11:50:24 m2 postfix/smtp[675]: 3595420E53: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=96368, delays=95743/0.02/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
1080: Feb 23 12:10:23 m2 postfix/smtp[1086]: C02C420E63: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=95839, delays=95213/0.01/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
1177: Feb 23 12:45:24 m2 postfix/smtp[1790]: A1F4C20E26: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=100753, delays=100127/0.01/26/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
1229: Feb 23 13:05:24 m2 postfix/smtp[2209]: 38F5020EB4: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=95848, delays=95222/0.02/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
1251: Feb 23 13:10:24 m2 postfix/smtp[2302]: 3595420E53: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=101168, delays=100543/0.05/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
1330: Feb 23 13:30:24 m2 postfix/smtp[2717]: C02C420E63: to=<[email protected]>, relay=mail.mailserver2.com[5.6.7.8]:25, delay=100640, delays=100014/0.04/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver2.com[5.6.7.8] timed out while sending end of data -- message may be sent more than once)
1410: Feb 23 14:05:23 m2 postfix/smtp[3399]: A1F4C20E26: to=<[email protected]>, relay=mail.mailserver1.com[1.2.3.4]:25, delay=105552, delays=104927/0.02/25/600, dsn=4.4.2, status=deferred (conversation with mail.mailserver1.com[1.2.3.4] timed out while sending end of data -- message may be sent more than once)
服务器正在无限循环地重新发送电子邮件,每 1.5 小时向用户发送一次垃圾邮件,可能直到达到 maximal_queue_lifetime。这对我们来说当然是一个巨大的问题,所以我在这里有几个问题:
1,我不认为这是我们的 postfix 的问题,这只是 10k 中的 4 个用户(2 个邮件服务器)的问题。无论如何,有人见过这种情况吗?可以修复吗?我所能找到的只是有关收件人端旧的/坏的 cisco 路由器、MTU 问题和途中某处的数据包碎片/FW 问题的信息。我知道这可能是收件人服务器上的问题,但它不在我们的掌控之下,因此无法修复。
2、Postfix 知道该消息被发送了不止一次,它甚至将其写入日志。我如何才能强制 Postfix 不向邮箱发送垃圾邮件,并且每当它知道该消息可能被发送不止一次时,就认为它已送达和/或将其从队列中删除。只是这些,而不是全部延迟。我不在乎其他电子邮件是否会因此而无法送达。
3、特别是如果(2)不可能的话,是否可以禁用对特定域/邮件服务器的延迟电子邮件的重试?
或者还有其他方法可以解决这个问题?
谢谢
答案1
关于你的第二和第三个问题,我认为你可以调整以下参数,以便你的最大队列寿命假设是 1 小时,在这 1 小时内,您可以尝试 4 次(每 15 分钟尝试 1 次)。这应该会大大减少发送的电子邮件数量。
maximal_queue_lifetime =
maximal_backoff_time =
minimal_backoff_time =
queue_run_delay =
maximal_queue_lifetime(默认值:5d)
当投递因临时错误而失败,并且队列中的时间已达到 maximal_queue_lifetime 限制时,将消息视为无法投递。
时间单位:s(秒)、m(分钟)、h(小时)、d(天)、w(周)。默认时间单位为 d(天)。
如果仅尝试一次邮件投递,则指定 0。
更多信息请访问:http://www.postfix.org/postconf.5.html
另一个选择是使用以下方法定期删除延迟队列:后超级命令。您可以将其配置为 cronjob:
*/5 * * * * postsuper -d ALL deferred
您可以在这里查看 postsuper 手册页:http://www.postfix.org/postsuper.1.html
-dqueue_id 从指定的邮件队列中删除一个具有指定队列 ID 的消息(默认值:hold、incoming、active 和 deferred)。
To delete multiple files, specify the -d option multiple times, or specify a queue_id of - to read queue IDs from standard input. For example, to delete all mail with exactly one recipi- ent [email protected]: postqueue -j | jq ' # See JSON OBJECT FORMAT section in the postqueue(1) manpage select(.recipients[0].address == "[email protected]") | select(.recipients[1].address == null) | .queue_id ' | postsuper -d - Or the historical form: mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } # $7=sender, $8=recipient1, $9=recipient2 { if ($8 == "[email protected]" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d - Specify "-d ALL" to remove all messages; for example, specify "-d ALL deferred" to delete all mail in the deferred queue. As a safety measure, the word ALL must be specified in upper case.
当然,2) 和 3) 只是权宜之计,可能会影响 Postfix 服务器的其他用户。在某些情况下,邮件会因正当理由而被推迟,并且应该在队列中停留更长时间,否则不应被删除。
答案2
我也遇到过同样的问题,并将其追溯到一个过于急切的防火墙,如果这些字节被发送,它会丢弃连接的最后几个字节立即地关闭连接之前。
Postfix 充当 SMTP 客户端,发送CRLF.CRLF
以结束消息,如果启用了 SMTP 管道,它还会发送QUIT
并等待两个命令响应。SMTP 服务器处理了消息,处理了QUIT
,发送了两个命令响应并立即关闭了连接。防火墙丢弃了这两个命令响应,因此 Postfix 只注意到连接被关闭,并且有理由不确定消息是否已正确移交。
smtp_discard_ehlo_keywords = pipelining
通过在 之后让 Postfix 延迟来解决此问题CRLF.CRLF
。 对 的响应QUIT
仍然会丢失,但这不会产生任何不良影响。