我正在尝试设置 Postfix,当 MySQL 地址中存在将邮件转发给用户的别名记录时丢弃邮件nobody
。
所有发送的邮件[email protected]
都应被黑洞。
相反,当数据库记录设置为将地址转发到时nobody
,我将消息转发到我的个人电子邮箱中[email protected]
!
别名数据库工作正常:
postmap -q [email protected] mysql:/etc/postfix/mysql/aliases.cf
nobody
别名设置如下:
cat /etc/aliases
nobody: /dev/null
我已经跑了newaliases
。
我在日志中没有看到任何可以解释为什么这封邮件发送给我的内容:
tail -f /var/log/mail.log -n0 | grep [email protected]
< unknown[xx.xx.xx.xx]: RCPT TO:<[email protected]>
extract_addr: input: <[email protected]>
smtpd_check_addr: [email protected]
send attr address = [email protected]
input attribute value: [email protected]
rewrite_clnt: local: [email protected] -> [email protected]
send attr address = [email protected]
input attribute value: [email protected]
resolve_clnt: `[email protected]' -> `[email protected]' -> transp=`lmtp' host=`inet:[xx]:xx' rcpt=`[email protected]' flags= class=virtual
ctable_locate: install entry key [email protected][email protected]
extract_addr: in: <[email protected]>, result: [email protected]
ctable_locate: leave existing entry key [email protected][email protected]
maps_find: recipient_canonical_maps: [email protected]: not found
mail_addr_find: [email protected] -> (not found)
maps_find: canonical_maps: [email protected]: not found
mail_addr_find: [email protected] -> (not found)
这里我们看到它nobody
在 MySQL 数据库中找到了别名:
maps_find: virtual_alias_maps: mysql:/etc/postfix/mysql/aliases.cf(0,lock|fold_fix|utf8_request): [email protected] = nobody
mail_addr_find: [email protected] -> nobody
ctable_locate: leave existing entry key [email protected][email protected]
milter_macro_lookup: result "[email protected]"
ctable_locate: leave existing entry key [email protected][email protected]
ctable_locate: leave existing entry key [email protected][email protected]
milter8_rcpt_event: milter local:opendkim/opendkim.sock: rcpt <[email protected]>
event: SMFIC_RCPT; macros: {rcpt_addr}[email protected] {rcpt_host}=inet:[redacted] {rcpt_mailer}=lmtp
现在它决定将邮件发送给我而不是丢弃它:
D27032507A: to=<[email protected]>, orig_to=<[email protected]>, relay=[redacted], delay=0.47, delays=0.15/0/0.19/0.13, dsn=2.0.0, status=sent (250 2.0.0 <[email protected]> 4u2+BSk8XWWpDwAA0J78UA Saved)
[email protected]
我正在向发送测试电子邮件[email protected]
。但没有设置别名,因此我无法domain.com
在我的电子邮件地址 @收到任何邮件otherdomain.com
。
我怎样才能让 Postfix 丢弃发送给我的邮件[email protected]
而不是将其全部转发给我?
更新
该问题与 Postfix 无法向本地用户传递邮件有关。
如果我仅使用nobody
别名表中的作为目的地,它会被重写为,其中[email protected]
domain.com 是 的值。myhostname
main.cf
如果我将转发记录设置为指向nobody@localhost
,则邮件会反弹:
<nobody@localhost> (expanded from <[email protected]>):
mail for localhost loops back to myself
答案1
在虚拟别名表中,创建别名@localhost
,即:
[email protected] -> trash@localhost
如果你只是使用trash
它将解决[email protected]
将转发到错误的地方或失败。
另外,请确保守护local
进程已启用master.cf
并且localhost
位于本地目标列表中:
mydestination = localhost