4月 042010
 

[postfix procmail Maildir]procmail 與 Maildir 信箱格式的搭配

以前使用 procmail + spamassassin 過濾垃圾信,只會搭配 mbox 信箱使用,後來為了設定用戶信箱的 qutoa ,將信箱格式改為 Maildir/ 目錄信箱格式,就不再使用 procmail ,而改用 amavisd-new 了。

現在放棄 amavisd-new ,回頭改用 procmail ,搭配 Maildir/ 的問題得想辦法解決。終於給我搞定了,紀錄如下:

在契而不捨的搜尋下,終於找到了這篇討論:

http://www.redhat.com/archives/rhl-list/2005-January/msg00974.html

依照討論裡的方法並稍加修改,將 /etc/procmailrc 設定如下:

LOGFILE=/var/log/procmail.log
DROPPRIVS=yes
DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir

:0fw
| /usr/local/bin/spamc

然後建立 procmail.log 檔:

touch /var/log/procmail.log

接著設定 postfix 將郵件遞送給 procmai :

postconf -e mailbox_command=/usr/bin/procmail
/etc/rc.d/init.d/postfix reload

果然成功了!可以從 procmail.log 裡看到信件被 spamassassin 過濾加標籤,並正確遞送到收件者的 Maildir 目錄下。

可惜,好景不常,如果不用管使用者 quota 的話,世界應該是美好的。 spamc / spamd 一陣子後就無緣無故失效了,信件被 procmail 遞送到 /var/mail/userxxx 信箱去了。

/var/log/mail/info.log 裡的相關紀錄之一:

procmail: Quota exceeded while writing “/home/userblahblah/Maildir/tmp/1192780146.5838_0.mail”

於是,修改後的 /etc/procmailrc 第二版如下:

LOGFILE=/var/log/procmail.log
DROPPRIVS=yes
DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir

:0fw
| /usr/local/bin/spamc

# 如果發生錯誤則離開,以免搞亂之後的 spamc /spamd 執行環境。
:O E
{
EITCODE=127
}

這樣做可以解決部份問題,但是超過 quota 的用戶,信件並沒有被退回,還是送到 mbox 信箱去。

我想,這是因為 mailbox_command 是 postfix 用來取代遞送信件到信箱的動作,所以由 procmail 接手後, postfix 便認為信件遞送動作完成,不會處理無法寄達信箱的退信了。

好,這個方法要組合 postfix ( Maildir/ ) + procmail + spamassassin 來過濾垃圾信應該是不可行了,要另尋他法。不過,至少玩出了 procmail + Maildir 的用法,也算是有收獲。
張貼者: lss 於 2007年10月23日 23:06

  2 条评论 到 “[postfix procmail spamassassin]搞定垃圾郵件過濾最終解決方案”

  1. chanxiong

    你好,看你的文章受益匪浅,能否把「 [postfix procmail Maildir]procmail 與 Maildir 信箱格式的搭配」 发给我,我找不到。谢谢。

 回复

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>