続続続・My IMAPサーバ構築
いよいよ設定です。以下のサイトが参考になりました。
設定内容です。
protocols = imap default_mail_env = maildir:~/Maildir
- dovecotの起動は、/etc/init.d/dovecot start
- ホームディレクトリに.fetchmailrcを作成。設定は参考サイトからコピーして作成。しばらくはflushをkeepにした方が安全です。仕事のメールが誤って消えたら最悪ですからね・・・
- ポイントは、procmailで振り分けるために、「mda "/usr/bin/procmail"」とすること。
set logfile "/home/hirohiro/fetchmail.log" set postmaster root set no bouncemail defaults protocol pop3 keep no mimedecode mda "/usr/bin/procmail" poll mail.mycompany.com protocol pop3 user hirohiro password pass
- さらに、fetchmailを一定間隔で実行するためのスクリプトを用意。適当メモ - maple4estry - >> Fedora CORE (2) + postfix + dovecot + fetchmail で メール処理用IMAPサーバを作るに記載されているものを利用させて頂きました。どうもありがとうございます。
# vi /etc/init.d/fetchmail # chkconfig: 345 99 20 # # description: Fetchmail auto start script # Source function library. . /etc/rc.d/init.d/functions # See how we were called. case "$1" in start) for user in `ls /home/` do if [ -f /home/$user/.fetchmailrc ]; then echo "fetchmail for $user starting..." su $user -c "/usr/bin/fetchmail --daemon 180" fi done ;; stop) # Stop daemons. for user in `ls /home/` do if [ -f /home/$user/.fetchmailrc ]; then echo "fetchmail for $user stoping..." su $user -c "/usr/bin/fetchmail --quit" fi done ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0
ファイルを作成したら、/etc/init.d/fetchmail start で起動します。
- ホームディレクトリに.procmailrcを作成。こんな感じで正規表現を駆使して振り分けルールを作成していきます。
PATH=$HOME/bin:/usr/bin:/usr/local/bin MAILDIR=$HOME/Maildir/ DEFAULT=$MAILDIR LOCKFILE=$HOME/.lockmail :0 * ^From:.*(\.|@)sourceforge\.net .ML :0 * ^From:.*(\.|@)yahoogroups\.jp .ML
完成!