后缀 – 从relayhost排除具有特定标头值的消息?

从以下基本configuration开始,将Postfix中的所有消息转发到PostMarkApp.com:

#start postmarkapps settings smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:secret:secret (where "secret is your API key") smtp_sasl_security_options = noanonymous relayhost = [smtp.postmarkapp.com]:25 #end postmarkapp settings 

这个问题是,如果例如东西开始吐出错误信息,他们将通过PostMark和花费金钱。

一种绕过relayhost是设置sender_dependent_relayhost_maps并将某些地址映射回yourdomain.com。 但是,这不适用于所有消息由同一用户发送,但具有不同From标头的Web应用程序。

那么我怎样才能达到与sender_dependent_relayhost_maps相同的效果,但是sender_dependent_relayhost_maps用户的From或Subject标题呢?

你需要Postfix 2.5或更高版本。

然后在main.cf设置smtp_header_checks = pcre:/etc/postfix/dont_relay_this_header

/etc/postfix/dont_relay_this_header写入

 /^Subject:.*viagra/ REJECT You are not allowed to send out advertisement 

根据需要更改dont_relay_this_header文件的内容。 header_checks手册中提供了更多信息。

我通过从另一端攻击来解决这个问题,即不要通过中继主机发送邮件到某个收件人。

编辑/etc/postfix/main.cf

 #start postmarkapps settings transport_maps = hash:/etc/postfix/transport smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:secret:secret (where "secret is your API key") smtp_sasl_security_options = noanonymous relayhost = #end postmarkapp settings 

编辑/etc/postfix/transport

 [email protected] : * smtp:[smtp.postmarkapp.com]:25 

运行postmap /etc/postfix/transport

现在,我只是将所有的错误消息发送到[email protected],而不是通过PostMark发送。