Postfix基于域重写收件人

我正在寻找一个后缀configuration来创build基于收件人域名的收件人重写规则,包括捕获所有在“不重写”列表中找不到的域。 例如:

理想将是不应该通过Postfix重写的域列表。 现在我使用一个没有例外的设置,所以一切都被重写了:

recipient_canonical_maps = static:@spam.example.com

在main.cf中添加(删除现有的静态地图):

 recipient_canonical_maps = pcre:/etc/postfix/rcpt_canonical_maps 

在/ etc / postfix / rcpt_canonical_maps(把domain1.comreplace成你的'good'域):

 if !/^(.*)@(domain1.com|domain2.com|domain3.com)$/ /^(.*)@.*$/ REDIRECT ${1}@spam.example.com endif 

请不要,我还没有testing过,但我相当有信心,这将做你所需要的。

话虽如此,我应该强调在非生产环境中testing这一点非常重要。

谢谢你,亚伦,你的回答帮了我很多。 我可以确认以下设置适用于我当前运行的后缀设置(稳定的Ubuntu 14.04)。

我已经将以下内容添加到main.cf

 # Receive all emails and rewrite the destination because of testing. recipient_canonical_maps = regexp:/etc/postfix/recipient_canonical_maps 

我的recipient_canonical_maps如下所示:

 !/.*@example.com/ @spam.example.com