fetchmail + procmail + spamassassin + wonderlust

Debian GNU/Linux squeezeインストール覚書の続き。

メールを fetchmail + procmail + spamassassin + wonderlustという環境で受け取っているのでこれの設定のメモ。

まずは、必要なものを全部インストール。

# aptitude install fetchmail procmail spamassassin wl

fetchmailでPOPサーバからメールを定期的に受信し、それをprocmail経由でspamassassinに渡す。受信したメールはMaildir方式で保存し、wonderlustで読み書きする。

まずは、fetchmailの設定を行う。~/.fetchmailrcを以下のように作る。

set daemon 300
set nobouncemail

poll POPサーバのIPかFQDN
     protocol pop3
     user POPサーバのログインユーザー名
     password POPサーバのログインパスワード
     ssl
     fetchall
     nokeep
     no mimedecode
     mda "/usr/bin/procmail -p -f %F"

また、Linuxの起動時にfetchmailをデーモンとして機動さえるために、/etc/default/fetchmailを編集する。

# This file will be used to declare some vars for fetchmail
#
# Uncomment the following if you don't want localized log messages
# export LC_ALL=C

# If you want to specify any additional OPTION to the start
# scripts specify them here
# OPTIONS=...

# Declare here if we want to start fetchmail. 'yes' or 'no'
#START_DAEMON=no
START_DAEMON=yes

procmailの設定は~/.procmailrcで設定する。メールの配送先ディレクトリとspamassasinの呼び出しを行う。この設定では、メールは~/Mail/inboxに配送される。スパムと思しきメールは、~/Mail/doubtへ、スパムと判定されたメールは~/Mail/spamへ配送される。

PATH=/bin:/usr/bin:/usr/local/bin
MAILDIR=$HOME/Mail
DEFAULT=$MAILDIR/inbox/.
LOGFILE=$MAILDIR/procmaillog
LOCKFILE=$HOME/.lockmail
SPAM=$MAILDIR/spam/.
DOUBT=$MAILDIR/doubt/.

# call SpamAssassin
:0fw: spamassassin.lock
* < 600000
| spamassassin

:0H:
* X-Spam-Flag: YES
* X-Spam-Status:.*autolearn=spam
$SPAM

自動的にスパム判定から除きたいメールアドレスは~/.spamassassin/user_prefsにて設定する。

  • whitelist_from hogehoge@ne.jp (From欄がhogehoge@ne.jpならばスパムではないと自動的に判定)
  • whitelist_to hogehoge@ne.jp (To欄がhogehoge@ne.jpならばスパムではないと自動的に判定)

wonderlustの設定は~/.wlで行う。以下の内容を付け加える。

;; fetchmail用の設定
(setq elmo-localdir-folder-path "~/Mail")

;; SMTP サーバの設定
(setq wl-smtp-posting-server "SMTPサーバーのIPかFQDN")