2006-12-21 16:26:05過路人而已

Postfix with SpamAssassin 設定

Postfix with SpamAssassin
紀錄一下如何在 Debian 上設定基本的 SpamAssassin 搭配 Postfix.

首先要先有一個已經在運作中的 Postfix , 可以參考此篇完成安裝與使用:
http://moto.debian.org.tw/viewtopic.php?t=2111&highlight=postfix+amavis

執行 apt-get install spamassassin

修改 /etc/default/spamassassin
將 ENABLED=0 修改成 ENABLED=1

修改 /etc/postfix/master.cf
將 smtp inet n - n - - smtpd 修改成 smtp inet n - n - - smtpd -o content_filter=spamfilter:

並於 Interfaces to non-Postfix software 區段中加入以下內容
spamfilter unix - n n - - pipe flags=Rq user=postfixfilter argv=/usr/bin/postfixfilter -f ${sender} -- ${recipient}

將 /etc/postfix/master.cf 存檔離開.

建立一個檔案 /usr/bin/postfixfilter, 內容如下:
#!/bin/bash /usr/bin/spamc | /usr/sbin/sendmail -i "$@" exit $?

存檔離開後, 執行以下內容:
# groupadd postfixfilter
# useradd -g postfixfilter -m postfixfilter -s /bin/false
# chmod +x /usr/bin/postfixfilter
# chown postfixfilter:postfixfilter /usr/bin/postfixfilter

啟動 SpamAssassin 與 Postfix
# /etc/init.d/spamassassin start
# /etc/init.d/postfix restart

關於 SpamAssassin 的 local.cf 可參考此篇內容
http://scw.homeip.net/article/wakka.php?wakka=SpamAssassinInstallation