每条到本地用户的消息必须转到通过运行外部命令获得的地址。 该命令将查看本地地址标记,对几个进程进行API调用,然后计算目标地址。
例如,我们可以在用户的主目录中使用一个.forward文件来将消息传递给命令(| command),该命令也将负责转发消息。 “别名或〜/ .forward文件可以列出外部命令,目标文件名,:include:指令或邮件地址的任意组合。 请参阅:www.postfix.org/local.8.html另外:www.postfix.org/aliases.5.html
也许它只需要调整To头并通过Postfix重新发送消息? 有些事情告诉我这不是那么简单。 最简单的办法是Postfix自己处理整个转发作业,就像当目的地址直接写入.forward文件时一样。 但地址是未知的; 它只能由命令来确定。 这就是问题。
而且,如果不能确定目的地地址,则该消息必须以该命令提供的失败通知来弹跳。
这个解决scheme扩展了Danila的答案。 具体来说,它redirect某些wiki用户的邮件,称为“pipe道”[2],将其转发给维基中分配的“监护人”[1]。 但一般来说,它应该适用于目标地址由脚本dynamic确定的任何中继。
(a)在/etc/postfix/main.cf文件中:
transport_maps = regexp:/etc/postfix/transport.regexp # enable transport mapping based on regular expressions minder_destination_recipient_limit = 1 # See SINGLE-RECIPIENT DELIVERY [3]. relay-to-minder (master.cf) can handle only a # single recipient per delivery, and flags DO have the same limitation.
(b)在文件/etc/postfix/transport.regexp [4]中,执行传输映射:
if /^pipe\+.+@zelea\.com$/ # relay all deliveries for pipe users [2] ... !/^pipe\+bounceSpam@/ minder: # ... except 'bounceSpam' deliveries, via master.cf 'minder' service endif
(c)在/etc/postfix/master.cf文件中,定义'看守'服务:
# ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ========================================================================== minder unix - nn - 1 pipe flags=DO user=pipe argv=/usr/local/libexec/relay-to-minder ${sender} ${recipient} # With maxproc 1 because it's sufficient, let Postfix do all queuing. # Both flags D and O (adding headers Delivered-To and X-Original-To) require main.cf # minder_destination_recipient_limit=1 [3]
(d)使用master.cf user =中指定的用户(pipe道)使relay-to-minder脚本可执行。 脚本的内容(包括这些configuration说明的最新版本)位于http://zelea.com/system/host/havoc/usr/local/libexec/relay-to-minder
该脚本重新解决目标标题(仍然不能确定是否正确),重新寻址信封,并将其反馈给MTA以供最终交付。
[1] zelea.com/w/Property:Minder
[2] zelea.com/w/Category:Pipe
[3]“pipe道”的含义与[2]不同。 www.postfix.org/pipe.8.html
[4] www.postfix.org/transport.5.html | www.postfix.org/regexp_table.5.html
请原谅他们的联系。 我没有得到足够的布朗尼点数。
正确的做法是在master.cf中创build一个新的传输
像这样的东西:
myscript unix - nn - 40 pipe flags=R user=vmail argv=/path/to/myscript -o SENDER=${sender} -m USER=${user} EXTENSION=${extension}
你可以使用你自己的参数。
那么你可以使用正则expression式来捕捉规则
transport_maps = regexp:/etc/postfix/redirect_or_forward.regexp
然后在/etc/postfix/redirect_or_forward.regexp
就像是:
/^user-.*@mydomain\.com/ myscript:
阅读后缀文档,这应该有更广泛的解释。 希望这可以帮助。