我有一个 postfix 邮件服务器,用于将发往我的域名的所有电子邮件转发*@example.com
到单个虚拟邮箱:[email protected]
。
我通过以下配置做到了这一点:
/etc/postfix/main.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf regexp:/etc/postfix/aliases-regexp
/etc/postfix/aliases-regexp
(应该转发任何内容不是已经去[email protected]
)
!/me@example\.com/ [email protected]
接收邮件正常:
postfix/smtpd[5852]: connect from unknown[108.60.212.145]
postfix/trivial-rewrite[5856]: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains
postfix/smtpd[5852]: E7D49E27: client=unknown[108.60.212.145]
postfix/cleanup[5857]: E7D49E27: message-id=<a197d7118eaedfb5@be0fdfd65ca8aeb2>
postfix/qmgr[5787]: E7D49E27: from=<[email protected]>, size=1700, nrcpt=1 (queue active)
postfix/smtpd[5852]: disconnect from unknown[108.60.212.145] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
postfix/pickup[5785]: 64CB91090: uid=1002 from=<[email protected]>
postfix/cleanup[5857]: 64CB91090: message-id=<a197d7118eaedfb5@be0fdfd65ca8aeb2>
postfix/qmgr[5787]: 64CB91090: from=<[email protected]>, size=2068, nrcpt=1 (queue active)
postfix/trivial-rewrite[5856]: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains
postfix/pipe[5858]: E7D49E27: to=<[email protected]>, orig_to=<[email protected]>, relay=spamassassin, delay=0.54, delays=0.13/0.01/0/0.4, dsn=2.0.0, status=sent (delivered via spamassassin service)
postfix/qmgr[5787]: E7D49E27: removed
postfix/lmtp[5862]: 64CB91090: to=<[email protected]>, relay=fqdn.example.com[private/dovecot-lmtp], delay=0.08, delays=0.02/0.03/0.02/0.02, dsn=2.0.0, status=sent (250 2.0.0 <[email protected]> 22w5HOfOilvnFgAASQqZ1w Saved)
postfix/qmgr[5787]: 64CB91090: removed
请注意以下这一行:
postfix/pipe[5858]: E7D49E27: to=<[email protected]>, orig_to=<[email protected]>, relay=spamassassin, delay=0.54, delays=0.13/0.01/0/0.4, dsn=2.0.0, status=sent (delivered via spamassassin service)
显示该消息原本是发给 的,[email protected]
但已送达[email protected]
。这很好。不幸的是,这种情况也会发生在发送过程中。这会导致发送的消息被退回给我。
postfix/lmtp[5862]: BA93CE27: to=<[email protected]>, orig_to=<[email protected]>, relay=fqdn.example.com[private/dovecot-lmtp], delay=0.22, delays=0.19/0/0.02/0.02, dsn=2.0.0, status=sent (250 2.0.0 <[email protected]> QzBoOSXPiluGGAAASQqZ1w Saved)
这是发送邮件时的完整日志:
postfix/trivial-rewrite[5856]: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains
postfix/submission/smtpd[6260]: BA93CE27: client=mail-pl1-f178.google.com[209.85.214.178], sasl_method=PLAIN, [email protected]
postfix/cleanup[5857]: BA93CE27: message-id=<CAHgoK_pUF=7qQ+fCRYcqKBPGqxK1fin-AjjoY5xr0GuUeDScow@mail.gmail.com>
postfix/qmgr[5787]: BA93CE27: from=<[email protected]>, size=4192, nrcpt=1 (queue active)
postfix/trivial-rewrite[5856]: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains
postfix/lmtp[5862]: BA93CE27: to=<[email protected]>, orig_to=<[email protected]>, relay=fqdn.example.com[private/dovecot-lmtp], delay=0.22, delays=0.19/0/0.02/0.02, dsn=2.0.0, status=sent (250 2.0.0 <[email protected]> QzBoOSXPiluGGAAASQqZ1w Saved)
postfix/qmgr[5787]: BA93CE27: removed
结果是我的消息似乎没有发送,甚至没有收到错误回复。
答案1
在 Postfix 中为域名创建 catch-all 有很多选项,您的选项比较复杂。通常的方法是使用virtual_alias_maps = hash:/etc/postfix/virtual
。使用 时@example.com me
请记住。postmap /etc/postfix/virtual
hash:
答案2
我通过改为解决了这个问题/etc/postfix/aliases-regexp
:
if /(.*)@example.com/
!/me@example\.com/ [email protected]
endif
if 语句首先检查邮件是否发往该域,不包括外发邮件。