Email

如何將註冊郵件退回到 noreply@ 郵件地址

  • August 20, 2017

在 CentOS 7 Linux 上,我執行 Drupal,它要求使用者確認他們的郵件地址。

我通過以下方式修改了後綴配置文件:

/etc/後綴/通用:

@www.localdomain noreply@preferans.de

/etc/postfix/main.cf:

smtp_generic_maps = hash:/etc/postfix/generic

這導致 Drupal 向新使用者發送註冊郵件,其中包含以下標題:

From: noreply@preferans.de     <--- non-existing address at my domain
Reply-To: First.Last@gmail.com <--- my private mail address

這很好用(比以前更好,當我設置From:為我的 Gmail 地址並且 Gmail 認為我的網站正在向其他人發送垃圾郵件時),但我有一個問題:

我不想再接受任何發給任何人的郵件@preferans.de(太多垃圾郵件湧入),所以我刪除了伺服器 DNS 條目中的 MX 記錄,並通過 iptables 關閉了埠 25。

現在當一個新的 Drupal 使用者輸入一個虛假地址時,註冊郵件會退回,noreply@preferans.de但我的 postfix 安裝無法傳遞它:

/var/log/maillog:

Aug 16 18:20:44 www postfix/master[1006]: daemon started -- version 2.10.1, configuration /etc/postfix
Aug 16 22:29:20 pref postfix/cleanup[9031]: 785952C03A8: message-id=<20170816202920.785952C03A8@pref.localdomain>
Aug 16 22:29:20 pref postfix/bounce[9033]: 5B56F2C03A7: sender non-delivery notification: 785952C03A8
Aug 16 22:29:20 pref postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 22:29:20 pref postfix/qmgr[24449]: 5B56F2C03A7: removed
Aug 16 22:29:22 pref postfix/smtp[9009]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 22:29:22 pref postfix/smtp[9009]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=1.5, delays=0/0/1.5/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)
Aug 16 22:38:51 pref postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 22:38:51 pref postfix/smtp[9208]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 22:38:51 www postfix/smtp[9208]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=571, delays=571/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)
Aug 16 22:48:51 www postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 22:48:51 www postfix/smtp[9393]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 22:48:51 www postfix/smtp[9393]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=1171, delays=1171/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)
Aug 16 23:08:51 www postfix/qmgr[24449]: CF37F2C039F: from=<noreply@preferans.de>, size=1234, nrcpt=1 (queue active)
Aug 16 23:08:51 www postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 23:08:51 www postfix/smtp[9797]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 23:08:51 www postfix/smtp[9797]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=2371, delays=2371/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)
Aug 16 23:08:51 www postfix/smtp[9796]: connect to gamai.com[67.227.226.241]:25: Connection refused
Aug 16 23:08:51 www postfix/smtp[9796]: CF37F2C039F: to=<vs20132013@gamai.com>, relay=none, delay=4588, delays=4588/0.01/0.13/0, dsn=4.4.1, status=deferred (connect to gamai.com[67.227.226.241]:25: Connection refused)
Aug 16 23:48:52 www postfix/qmgr[24449]: 785952C03A8: from=<>, size=3262, nrcpt=1 (queue active)
Aug 16 23:48:52 www postfix/smtp[10420]: connect to preferans.de[88.99.244.39]:25: Connection refused
Aug 16 23:48:52 www postfix/smtp[10420]: 785952C03A8: to=<noreply@preferans.de>, relay=none, delay=4772, delays=4772/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to preferans.de[88.99.244.39]:25: Connection refused)

隊列已滿:

# sudo mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
CF37F2C039F     1234 Wed Aug 16 21:52:22  noreply@preferans.de
                (connect to gamai.com[67.227.226.241]:25: Connection refused)
                                        vs20132013@gamai.com

785952C03A8     3262 Wed Aug 16 22:29:20  MAILER-DAEMON
               (connect to preferans.de[88.99.244.39]:25: Connection refused)
                                        noreply@preferans.de

BD4222C03B6     1219 Thu Aug 17 07:48:48  noreply@preferans.de
(host mx.yandex.ru[87.250.250.89] said: 451 4.5.1 The recipient <ebotstoreru@yandex.com> has exceeded their message rate limit. Try again later. 1502957639-8f63s3727h-Dw8G1QLj (in reply to end of DATA command))
                                        ebotstoreru@yandex.com

-- 6 Kbytes in 3 Requests.

我的問題是:

如何配置我的 postfix 安裝,以便它立即刪除未發送的郵件(但仍然通過灰名單)?

最後是目前的postconf -n輸出:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_generic_maps = hash:/etc/postfix/generic
unknown_local_recipient_reject_code = 550

我的解決方案是設置

bounce_queue_lifetime = 2d

/etc/postfix/main.cf中將退回郵件的生命週期縮短到 2 天

引用自:https://serverfault.com/questions/869100