SpamAssassinã¤ã³ã¹ãã¼ã«ã¡ã¢
æ¦è¦
SpamAssassinã¯ï¼Perlã§æ¸ãããSPAMãã£ã«ã¿ã§ãï¼SPAMã¨å¤æãããã¡ã¼ã«ã«å¯¾ããªãã·ã§ã³ãããã追å ãããã¨ãã§ãã¾ãï¼å©ç¨è å´ã¯ï¼SpamAssassinãä»ä¸ãããããæ å ±ããã¨ã«ãã´ãç®±ã«æ¯ãåããããªã©ã®ã«ã¼ã«ãIMAP4ã¯ã©ã¤ã¢ã³ãå´ãªã©ã§è¡ããã¨ã§ï¼SPAMã¡ã¼ã«ãå¹ççã«åä¿¡ç®±ããæé¤ãããã¨ãã§ãã¾ãï¼
ç°å¢
- FreeBSD 5-STABLE
- Postfix 2.4.0
- Maildirç°å¢
- SpamAssassin 3.1.8
- å ¬å¼WWWãµã¤ã: http://spamassassin.apache.org/
- æ¥æ¬SpamAssassinã¦ã¼ã¶ä¼: http://spamassassin.jp/
åèWWWãµã¤ã
- dfltweb1.onamae.com – このドメインはお名前.comで取得されています。
- ã¨ã¦ãæç¨ï¼procmailrcã®è¨å®ä¾ã¨ãï¼
(1) SpamAssassinãå°å ¥
# cd /usr/ports # portinstall mail/p5-Mail-SpamAssassin
ãªãã·ã§ã³é¸æãã¤ã¢ãã°ãåºãï¼"DomainKeys support"ã"Add SPF query support"ãããããï¼åä½ã®è©³ç´°ã(ç§ã)ç解ãã¦ããªãããï¼ããã§ã¯é¸æããï¼ããã©ã«ãã®ä»¥ä¸ã®é¸æè¢ã¾ã¾OKããï¼
(2) ã¤ã³ã¹ãã¼ã«ããããã¡ã¤ã«ç¾¤ã®ç¢ºèª
# pkg_info -L /var/db/pkg/p5-Mail-SpamAssassin-3.1.8_1/ Information for p5-Mail-SpamAssassin-3.1.8_1: Files: /usr/local/man/man1/spamd.1.gz /usr/local/man/man1/spamassassin.1.gz /usr/local/man/man1/spamc.1.gz /usr/local/man/man1/sa-learn.1.gz /usr/local/man/man1/sa-update.1.gz /usr/local/man/man1/spamassassin-run.1.gz :
manããã¡ãã¨å
¥ã£ã¦ããï¼ãã®ä»ï¼å種ããã¥ã¡ã³ãã®é
ç½®ç¶æ³ã確èªãã¦ããï¼
è¨å®ãã¡ã¤ã«ç¾¤ã¯ /usr/local/etc/mail/spamassassin 以ä¸ã«å
¥ã£ã¦ããããã ï¼
(3) ããã¥ã¢ã«ãã¼ã¸ã®ç¢ºèª
# man spamassassin
以ä¸ã®ãããªãã¨ããããï¼
- è¨å®ãã¡ã¤ã«ã®æ¸å¼ã確èªããã«ã¯ man Mail::SpamAssassin::Conf
- spamassassin-runã¯ããã³ãã¨ã³ãã»ãã£ã«ã¿ãªã³ã°ã»ã¹ã¯ãªãã
- spamcã¯ï¼spamdã®ã¯ã©ã¤ã¢ã³ã
- spamdãSpamAssassinã®ãµã¼ã
- è¨å®ãã¡ã¤ã«ãæ¤ç´¢ãããã¹
- ããããç´æçãªæ¤ç´¢é ã«ãªã£ã¦ãã
- ã¤ã³ã¹ãã¼ã«æ¹æ³ã¯ "INSTALL" ãèªãï¼ã¨ã®ãã¨ï¼
- /usr/local/share/doc/p5-Mail-SpamAssassin/INSTALL
# lv /usr/local/share/doc/p5-Mail-SpamAssassin/INSTALL
- Step.4: procmailãå¿ è¦ï¼ã¨ã®ãã¨ï¼
(4) procmailã®ã¤ã³ã¹ãã¼ã«
# cd /usr/ports/ # portinstall mail/procmail/
dfltweb1.onamae.com – このドメインはお名前.comで取得されています。ãåèã«ï¼procmailrcãæ¸ãï¼
/usr/local/etc/procmailrc
PATH=/bin:/usr/bin:/usr/local/bin MAILDIR=$HOME/Maildir DEFAULT=$MAILDIR/ LOGFILE=$MAILDIR/procmail.log # å¼ãµã¤ãã¯Maildirã§ã®éç¨ã§ããããï¼LOCKFILEã®è¨å®ã¯åé¤ # LOCKFILE=$HOME/.lockmail :0fw *!^X-Spam.* |/usr/bin/env LANG=C LC_ALL=C /usr/local/bin/spamc
å¼ãµã¤ãã§ã¯procmailrcã®è©³ç´°ã«ã¤ãã¦ã¯æ±ããªãï¼è©³ããç¥ããã人ã¯ä»¥ä¸ãã©ããï¼
- http://www.linux.or.jp/JM/html/procmail/man1/procmail.1.html
- http://www.jaist.ac.jp/~fjt/procmail.html
(5) è¨å®ãã¡ã¤ã«ãç·¨é (SmapAssassin)
http://tlec.linux.or.jp/topic.htmlã«ï¼ã¨ã¦ãããã¡ã³ããã³ã¹ããã¦ãããã°ãããå®ç¾©ãã¡ã¤ã«ãããã¾ãï¼ä»åã¯ããã使ããã¦ããã ããã¨ã«ãã¾ãï¼
# cd /usr/local/etc/mail/spamassassin # fetch -o local.cf http://tlec.linux.or.jp/docs/user_prefs
ç¶ãã¦ï¼local.cfã®å é é¨åã«ä»¥ä¸ã®è¡ã追å ï¼
use_bayes 0 rewrite_header Subject [SPAM] required_score 8.0 allow_user_rules 0 ifplugin Mail::SpamAssassin::Plugin::AWL auto_whitelist_path /var/db/spamassassin/auto-whitelist auto_whitelist_file_mode 660 endif
å¼ãµã¤ãã§ã¯ï¼SpamAssassinã®æã¤ãã¤ã¸ã¢ã³ã¹ãã ãã£ã«ã¿ã¯ä½¿ããããªãï¼ã¨ããããªã·ã®ããï¼local.cfã®1è¡ç®ã«"use_bayes 0"ã追å ããï¼ããã«ãããã¤ã¸ã¢ã³ã¹ãã ãã£ã«ã¿ã¯ç¡å¹ã«ãªãï¼ãã®ãããã¯åèªã好ã¿ã§ï¼
SpamAssassinç¨ã®ãã¼ã¿ãã£ã¬ã¯ããªãæã£ã¦ããï¼auto-whitelistãtouchãã¦ããï¼
# mkdir /var/db/spamassassin # chown spamd:spamd /var/db/spamassassin # chmod 770 /var/db/spamassassin # touch /var/db/spamassassin/auto-whitelist # chmod 660 /var/db/spamassassin/auto-whitelist # chown spamd:spamd /var/db/spamassassin/auto-whitelist # /usr/local/etc/rc.d/sa-spamd.sh start
(6) èµ·åãã¡ã¤ã«ãç¢ºèª (SmapAssassin)
# cd /usr/local/etc/rc.d/ # lv sa-spamd.sh
以ä¸ã®ãã¨ããããï¼
- spamd_enable="YES" ã/etc/rc.confã«è¿½å ããå¿ è¦ããã
(7) /etc/rc.confãç·¨é
spamd_enable="YES" spamd_flags="-u spamd -g spamd "
spamd_flagsã« "-c" ã®æå®ããã(ããã©ã«ã)ç¶æ ã ã¨ï¼åæã«ã¦ã¼ã¶ã®ãã¼ã ãã£ã¬ã¯ããªä»¥ä¸ã«user_prefsãçæããããã§ããï¼ç§ã¯æ°æã¡æªãåä½ã ã¨æããã®ã§å¤ããï¼ã¾ãï¼"-u" ã "-g" ãã©ã°ãªãã®ç¶æ ã ã¨ï¼nobodyã«setuidãã¦åãããã§ããï¼ãã®ãããã¯ã好ã¿ã§ï¼
(8) SpamAssassinãèµ·å
# /usr/local/etc/rc.d/sa-spamd.sh start Starting spamd.
ç¡äºã«èµ·åããã確èªï¼
# ps xa | grep spamd 16024 ?? Ss 0:01.07 /usr/local/bin/spamd -c -d -r /var/run/spamd/spamd.pi 16025 ?? S 0:00.00 spamd child (perl5.8.8) 16026 ?? S 0:00.00 spamd child (perl5.8.8)
/var/log/maillogãè¦ã¦ããï¼"ok_languages"ã®ãããã§ã¨ã©ã¼ãåºã¦ãããããªã®ã§ï¼è©²å½è¡ãã³ã¡ã³ãã«ãã¦ããï¼ç·¨éãçµãã£ããï¼SpamAssassinãåèµ·åï¼
# /usr/local/etc/rc.d/sa-spamd.sh restart Stopping spamd. Waiting for PIDS: 16024. Starting spamd.
(9) è¨å®ãã¡ã¤ã«ãå¤æ´ (Postfix)
ã¾ãï¼Postfixã®è¨å®ã確èªããï¼
# postconf mailbox_command mailbox_command = #
mailbox_commandã®è¨å®ã空ã§ãããã¨ã確èªãããï¼main.cfã«ä»¥ä¸ã®è¡ã追å ããï¼
mailbox_command = /usr/local/bin/procmail
(10) Postfixã¸è¨å®å¤æ´ãåæ
# postfix reload postfix/postfix-script: refreshing the Postfix mail system
è¨å®ãåæ ããããã¨ã確èªï¼
# postconf mailbox_command mailbox_command = /usr/local/bin/procmail
ãã®ç¶æ ã§ï¼SpamAssassinãæå¹ã«ãªã£ã¦ããã¯ãã§ããï¼
(11) åä½ç¢ºèª
以ä¸ã®ã³ãã³ãã§SMTPãµã¼ãã®åºããã°ãç£è¦ããï¼
# tail -f /var/log/maillog