Postfix开发服务器 – 拦截所有外发邮件

所以现在有几次我被客户接收到了从开发服务器发来的邮件,因为我没有清理数据库。 所以,作为一个额外的安全选项,我想确保从我的开发机器发送的所有邮件都被拒绝基于域或转发给我自己。

我发现了几个我所需要的问题。

在开发服务器上的Postfix,允许邮件只发送到一个域 – 这看起来不错,是我迄今为止已经实现,但对第一个答案的评论是正确的。 通过Sendmail发送的邮件似乎不使用此设置。

后缀:赶上传出的邮件和redirect – 这看起来不错,但更新运输没有做蹲我。

我也看了地址重写http://www.postfix.org/ADDRESS_REWRITING_README.html并阅读这篇博文http://rene.bz/redirect-all-outgoing-email-single-account-postfix/

我正在通过在命令行上使用-t参数来调用sendmail来testing它,

sendmail -t < mail 

“邮件”的内容在哪里

 Date: Tue Oct 11 11:25:22 2011 To: [email protected] Subject: test From: [email protected] test 

我一直在改变地址是我的gmail地址和example.com地址。 我想要所有的邮件去其他(工作)域。

到目前为止,我看到没有任何限制生效。

/ etc / postfix / transport看起来像这样;

 example.com : .example.com : * :discard 

我已经将这些行添加到main.cf中

 smtpd_recipient_restrictions = hash:/etc/postfix/my_access, reject transport_maps = hash:/etc/postfix/transport 

还请注意我使用的是与MAMP捆绑在一起的Postfix,并且已经通过MAMP编辑main.cf – 文件>编辑模板> main.cf

我认为,最简单的解决scheme,如果你想抓住所有传出的邮件,插入到/etc/postfix/main.cf

 virtual_alias_maps = static:your_local_user_name 

您应该安装pcre并创build一个虚拟别名文件:

 apt-get install postfix-pcre 

在mail.cf中:

 virtual_alias_maps = pcre:/etc/postfix/virtual 

在/ etc / postfix / virtual中:

 /.*@.*/ $user 

将$ userreplace为您的全包邮箱的用户帐户。 现在从该服务器发送的每一封邮件都将被捕获到邮箱中

例如,将relayhost设置为拒绝中继的服务器,例如您自己的邮件服务器。 这样,任何外发邮件都将被拒绝,并且其发送通知将发送到开发计算机上的邮局主pipe邮箱。