歡迎您光臨本站 註冊首頁

Spamassassin無法連接,求助

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

Spamassassin無法連接,求助

各位朋友,我給我們公司搭建了個postfix+extmail+mysql的電子郵局,垃圾郵件挺多,所以我想到了使用spamassassin來攔截垃圾郵件,安裝一切順利,我是按照以下的文檔來做的~
===================================================================================
設定
設定 SpamAssassin 設定檔
SpamAssassin 的設定檔是放在 /etc/mail/SpamAssassin/local.cf 裡面,而且個檔案裡面定義了很多簡查規則,以下,我把最簡單的設定列出來。
#多少分才判為 SPAM
required_hits 5
report_safe 1
#若為 SPAM,是否設修改主旨
rewrite_subject 1
#修改主旨為 (當 rewrite_subject 是 1 的時候才會有用)
rewrite_header Subject

# Encapsulate spam in an attachment
report_safe 1

# Use terse version of the spam report
use_terse_report 1

# Enable the Bayes system
use_bayes 1

# Enable Bayes auto-learning
auto_learn 1

# Enable or disable network checks
skip_rbl_checks 0
use_razor2 1
use_dcc 1
use_pyzor 1

# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
# - chinese english japanese
ok_languages zh en ja

# Mail using locales used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_locales en ja zh

這樣做,就可以把基本的 SpamAssassin 設定起來。
新增一個 spamfilter 使用者
這個 spamfilter 主要是 spamd 會使用的,所以請建立起來,當然這個帳號是不允許從外面登入的:

root # useradd -s /bin/false spamfilter
編寫 filter script
root # touch /usr/local/sbin/filter.sh
root # vi /usr/local/sbin/filter.sh
#!/bin/bash
exec /usr/bin/spamc -d 127.0.0.1 -f -p 783 -t 30 -e /usr/sbin/sendmail -i "$@"
exit $?
root # chmod 755 /usr/local/sbin/filter.sh
你可以 按這裡 下載 filter.sh。
設定 postfix
再來,我們需要再設定 postfix 一下,讓 postfix 在接收信件時,使用 SpamAssassin 來做信件過瀘。其中會設定到最重要的 /etc/postfix/master.cf 檔,所要請記得要特別小心!
root # vi /etc/postfix/master.cf
~ 略 ~
#修改以下兩個項目
smtp inet n - n - - smtpd -o content_filter=postfixfilter
smtp unix - - n - - smtp -o content_filter=postfixfilter
~ 略 ~
# 在最後一行加入以下句子
postfixfilter unix - n n - - pipe flags=Rq user=spamfilter
argv=/usr/local/sbin/filter.sh -f ${sender} -- ${recipient}
root #
設定了 master.cf 之後,如果你在 main.cf 有設定其它的垃圾郵件規則的話,像是 header_checks 和 body_checks 的話,就請關閉吧,這種全文分析的工作可以讓 SpamAssassin 來做就可以了。
root # vi /etc/postfix/master.cf
#把 header_checks 和 body_checks 註解起來
#header_checks = regexp:/etc/postfix/header_checks
#body_checks = regxp:/etc/postfix/body_checks
root #
重新啟動 postfix 和 SpamAssassin
root # postfix stop; sleep 3; postfix start
root # service spamassassin start
測試
當然要測試最直接的方法就是使用 telnet
root # telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to mail-test.l-penguin.idv.tw (127.0.0.1).
Escape character is '^]'.
220 l-penguin.idv.tw ESMTP Postfix
MAIL FROM: babiku007@yahoo.com.tw
250 Ok
RCPT TO: someone@your.domain.name
250 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Test SPAM mail
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
.
250 Ok: queued as 450BFC6249
quit
221 Bye
Connection closed by foreign host.
root #
===================================================================================
我就是按照這個文檔來設定spamassassin和postfix的,但是現在有個問題,就是我的postfix和spamassassin都重啟了之後,我telnet 25埠發郵件的時候,maillog里有如下記錄:
May 27 13:36:58 mail postfix/smtpd: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
May 27 13:36:58 mail postfix/smtpd: connect from mail.3stonesoft.com
May 27 13:37:16 mail postfix/smtpd: BD42A6701E1: client=mail.3stonesoft.com
May 27 13:37:45 mail postfix/cleanup: BD42A6701E1: message-id=<20090527053716.BD42A6701E1@mail.3stonesoft.com>
May 27 13:37:45 mail postfix/qmgr: BD42A6701E1: from=<www@eee.com>, size=429, nrcpt=1 (queue active)
May 27 13:37:45 mail spamc: connect(AF_INET) to spamd at 127.0.0.1 failed, retrying (#1 of 3): Connection refused
May 27 13:37:46 mail spamc: connect(AF_INET) to spamd at 127.0.0.1 failed, retrying (#2 of 3): Connection refused
May 27 13:37:47 mail postfix/smtpd: disconnect from mail.3stonesoft.com
May 27 13:37:47 mail spamc: connect(AF_INET) to spamd at 127.0.0.1 failed, retrying (#3 of 3): Connection refused
May 27 13:37:48 mail spamc: connection attempt to spamd aborted after 3 retries
May 27 13:37:49 mail postfix/pickup: 00A936703E9: uid=99 from=<www@eee.com>
May 27 13:37:49 mail postfix/pipe: BD42A6701E1: to=<sunsiyao@3stonesoft.com>, orig_to=<sunsiyao>, relay=postfixfilter, delay=39, delays=36/0/0/3, dsn=2.0.0, status=sent (delivered via postfixfilter service)
May 27 13:37:49 mail postfix/qmgr: BD42A6701E1: removed
May 27 13:37:49 mail postfix/cleanup: 00A936703E9: message-id=<20090527053716.BD42A6701E1@mail.3stonesoft.com>
May 27 13:37:49 mail postfix/qmgr: 00A936703E9: from=<www@eee.com>, size=545, nrcpt=1 (queue active)
May 27 13:37:49 mail postfix/virtual: 00A936703E9: to=<sunsiyao@3stonesoft.com>, relay=virtual, delay=0.03, delays=0.01/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)
May 27 13:37:49 mail postfix/qmgr: 00A936703E9: removed
===================================================================================
請問為什麼會出現紅字那樣的情況,我用telnet本機的783埠也不成功:
# telnet 127.0.0.1 783
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
SPAMD/1.0 76 Bad header line: (closed before headers)
Connection closed by foreign host.

但是:
tcp        0      0 127.0.0.1:783               0.0.0.0:*                   LISTEN      23616/spamd.pid

23616 ?        Ss     0:00 /usr/bin/spamd -d -c -m5 -H -r /var/run/spamd.pid
23619 ?        S      0:00 spamd child
23620 ?        S      0:00 spamd child
進程和埠都正常啊,為什麼呢,我在網上找了好久都沒有找到解決的辦法,請朋友們幫幫忙!謝謝!
《解決方案》

頂下:em16: :em16: :em16:
《解決方案》

telnet localhost 783看看是什麼?
《解決方案》

頂到2010年!!不知樓主的問題解決沒有
《解決方案》


[火星人 ] Spamassassin無法連接,求助已經有702次圍觀

http://coctec.com/docs/service/show-post-17928.html