Postfix - 從中繼主機排除具有特定標頭值的訊息?

Postfix - 從中繼主機排除具有特定標頭值的訊息?

從以下基本配置開始,將 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那麼,如何才能達到與查看「寄件者」或「主題」標題而不僅僅是用戶相同的效果呢?

答案1

您需要 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 檔案的內容。更多資訊可在標頭檢查手動的。

答案2

我透過從另一端攻擊它來解決這個問題,即不透過中繼主機將郵件發送到某個收件者。

編輯/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

現在我只是將所有錯誤訊息發送到[電子郵件受保護]並且它們不是透過 PostMark 發送的。

相關內容