Linux伺服器---郵件服務spam

一生有你llx發表於2019-02-22

安裝spam

spam (SpamAssassin)利用perl來進行文字分析,他會檢測郵件的標題、內容、送信人,這樣就可以過濾出垃圾郵件

1 、安裝spam。由於spam的依賴太多,使用者一定要使用yum源來安裝,這樣減少不必要的麻煩 

[root@localhost ~]#  rpm -qa | grep spamassassin

[root@localhost openwebmail]#  yum install -y spamassassin

Complete!

 

2 、配置postfix使用spam功能,修改配置檔案“/etc/postfix/master.cf”

[root@localhost ~]#  gedit /etc/postfix/master.cf

smtp      inet  n      -       n       -      -       smtpd  -o content_filter=spamassassin

spamassassin unix - n n  - - pipe user=nobody argv=/usr/bin/spamc -f /usr/sbin/sendmail -oi -f $(sender) -- $(recipient)  // 追加到最後一行

 

3 、重啟postfix 

[root@localhost openwebmail]#  service postfix restart

關閉 postfix                                             [ 確定 ]

啟動 postfix                                             [ 確定 ]

[root@localhost openwebmail]#

 

4 、啟動spam服務

[root@localhost ~]#  service spamassassin start

啟動 spamassassin                                             [ 確定 ]

[root@localhost ~]#

 

5 、測試垃圾郵件。

1 )spamassassin為我們提供了一個垃圾郵件的模板“sample-spam.txt”,我們可以使用此模板的內容來傳送

[root@localhost openwebmail]#  cat /usr/share/doc/spamassassin-3.3.1/sample-spam.txt 

Subject: Test spam mail (GTUBE)

Message-ID: <GTUBE1.1010101@example.net>

Date: Wed, 23 Jul 2003 23:30:00 +0200

From: Sender <sender@example.net>

To: Recipient <recipient@example.net>

Precedence: junk

MIME-Version: 1.0

Content-Type: text/plain; charset=us-ascii

Content-Transfer-Encoding: 7bit

 

This is the GTUBE, the

    Generic

    Test for

    Unsolicited

    Bulk

    Email

If your spam filter supports it, the GTUBE provides a test by which you

can verify that the filter is installed correctly and is detecting incoming

spam. You can send yourself a test mail containing the following string of

characters (in upper case and with no white spaces and line breaks):

 

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X      // 這就是垃圾郵件的內容

 

You should send this test mail from an account outside of your network.

2 )使用openwebmail發信

3 )檢視郵箱的日誌檔案。Spam採用積分制,預設超過5分就是垃圾郵件,而我們看到下面識別出的郵件是999分,很明顯是垃圾郵件

[root@localhost openwebmail]#  cat /var/log/maillog

Aug 21 08:44:14 localhost spamd[6401]: spamd: failed to create readable default_prefs: //.spamassassin/user_prefs

Aug 21 08:44:14 localhost spamd[6401]: spamd: processing message <20180821004332.M42441@mailsrv.david.cn> for nobody:99

Aug 21 08:44:26 localhost spamd[6401]: spamd:  identified spam (999.0/5.0)  for nobody:99 in 12.5 seconds, 603 bytes.

Aug 21 08:44:26 localhost spamd[6401]: spamd: 

result: Y 999 – 

ALL_TRUSTED,GTUBE,TVD_SPACE_RATIO scantime=12.5,size=603,user=nobody,uid=99,required_score=5.0,rhost=localhost,raddr=127.0.0.1,

rport=33149,mid=<20180821004332.M42441@mailsrv.david.cn>,autolearn=no

Aug 21 08:44:26 localhost postfix/pipe[6443]: 3F2FD14141A: to=<david@mailsrv.david.cn>,

relay=spamassassin, delay=13, delays=0.06/0.03/0/12, dsn=2.0.0, status=sent (delivered via spamassassin service)

Aug 21 08:44:26 localhost postfix/qmgr[6368]: 3F2FD14141A: removed

Aug 21 08:44:26 localhost spamd[6399]: prefork: child states: II

 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29270124/viewspace-2286326/,如需轉載,請註明出處,否則將追究法律責任。

相關文章