我有一个服务器托pipe一个允许发送电子邮件的Java应用程序。 在testing期间,我希望Postfix将所有发出的电子邮件发送到[email protected],但是发送到[email protected]的电子邮件需要单独保留。
基本上:
[email protected] --> [email protected] *@* --> [email protected] 我想分享一些在我的使用情况下工作的configuration(将所有邮件发送到我的本地邮箱,而不pipeinput的是什么配方)。
运行Ubuntu 14.04,后缀版本2.11.0
/etc/postfix/main.cf添加到/etc/postfix/main.cf
sender_canonical_maps = regexp:/etc/postfix/sender_canonical recipient_canonical_maps = regexp:/etc/postfix/recipient_canonical transport_maps = hash:/etc/postfix/transport
用内容创build/etc/postfix/transport
* : yoshi
创build/etc/postfix/sender_canonical
/.+/ [email protected]
创buildetc/postfix/recipient_canonical/
/.+/ [email protected]
更新configuration:
sudo postmap /etc/postfix/transport sudo postmap /etc/postfix/recipient_canonical sudo postmap /etc/postfix/sender_canonical
重新启动后缀:
sudo service postfix restart
现在,如果我运行例如下面的脚本:
<?php mail("[email protected]", "PseudoFaullt to local Inbox", "This is a manual scam mail, please steal money from yourself.\nThank you for the cooperation");
我在本地收件箱中收到了一个重写的配方。 其实我不确定你是否需要发件人和运输configuration,但是我有这样的印象。 所以你可能想试试缩短这个过程。
注意/etc/postfix/main.cf中的*_maps*指令的前缀是regexp:而不是hash: *_maps*
所以对于你唯一的例外,也许一个机智的正则expression式可以做这个工作。
有关设置postfix,本地收件箱以及如何使用Thunderbird访问它们的非常详细的答案:
https://askubuntu.com/a/209877
有关sender_canonincal_maps信息:
http://binblog.info/2012/09/27/postfix-rewrite-the-sender-address-of-all-outgoing-mail/
您可以使用在这里和这里的 Postfix文档中指定的规范映射 。
在main.cf中
recipient_canonical_maps = regexp:/etc/postfix/canonical_maps_recipient
然后创build/ etc / postfix / canonical_maps_recipient并使用postmap进行编译
/[email protected]/ [email protected] /.*/ [email protected]
您可以使用此处的Postfix文档中所述的通用映射。 如果您需要其他地址重写规则,则此文档还提供了必要的步骤。