Tuesday, July 18, 2006

Spamassassin false-positive roaming users

一個好的 mail server 要能提供使用者安全、方便的使用方式,SMTP/TLS, POP3S 都是最低配備,還要加上 spam filter, anti-virus 才算完整。我目前是使用 postfix + dovecot + amavis + spamassassin + clamav 的組合,在 ubuntu 上安裝、設定都很簡單(ubuntu 有相當好的文件),運行起來也很正常。

但對於需要從外部 IP 發信的使用者,常會因為所使用的動態 IP 等因素,被 SA 判斷為 UBE,進而造成無法發信。這問題有兩種解法。

方法一是使用 postfix 2.3 以後版本。postfix 2.3 新增了 smtpd_sasl_authenticated_header 參數,會對通過 SASL 認證的使用者新增 mail header,SA 就不會再把外部 user 的信給視為 UBE 了。在 /etc/postfix/main.cf 中加入

smtpd_sasl_authenticated_header = yes


方法二設定上比較複雜一點,但是適用在 postfix 2.3 之前版本(如 ubuntu 上的 postfix 目前就只有 2.2.10)。修改 /etc/postfix/main.cf

smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, check_client_access pcre:/etc/postfix/filter.pcre
content_filter =

新增 /etc/postfix/filter.pcre,內容為

/./ FILTER smtp-amavis:[127.0.0.1]:10024

此處的 smtp-amavis:[127.0.0.1]:10024 請依照 master.cf 中的設定來設。使用 ubuntu 的人別忘了 apt-get install postfix-pcre。

這個方法的缺點就是只要通過 SASL 認證之後,就不會進行 content filter 程序,所以 spamassassin 跟 clamav 都不會作用。當然還有別的設法,但最好的方式,如果可行的話,就升級到 postfix 2.3 吧!關於這個問題這裡有很好的討論串。

No comments: