root@tea:/usr/ports/mail/mailscanner # uname -a
FreeBSD tea.sinomatrix.com 10.0-RELEASE FreeBSD 10.0-RELEASE #0: Mon Jan 12 14:16:48 CST 2015     user@tea:/usr/src/sys/i386/compile/tea  i386
root@tea:/usr/ports/mail/mailscanner # date
Mon Jan 12 16:11:49 CST 2015
root@tea:/usr/ports/mail/mailscanner #

1. 使用pkg install安裝mail scanner。會自動將所有相依的程式全部裝上。

root@tea:/etc/mail # pkg install mailscanner    <<<因為之前使用ports安裝一直失敗,所以試用pkg install安裝。
會自動把所有相關的檔案全部列出來問是否安裝?y

Fetch ...........................

再次確定是否安裝?y
......................(很快就裝完了,沒有任何Error)

 

2. 手動新增MailScanner需要的目錄:

root@tea:/usr/ports/mail/mailscanner # cd /var/spool
root@tea:/var/spool # mkdir mqueue.in
root@tea:/var/spool # mkdir MailScanner
root@tea:/var/spool # cd MailScanner/
root@tea:/var/spool/MailScanner # mkdir incoming
root@tea:/var/spool/MailScanner # mkdir quarantine
root@tea:/var/spool/MailScanner/incoming # mkdir Locks

3. 修改MTA:
root@tea:/var/spool/MailScanner #
root@tea:/usr/local/etc/rc.d # cd /usr/local/etc/rc.d/
root@tea:/usr/local/etc/rc.d # vi mta

# Sendmail, 3 instances (for MailScanner):
#
 mta_enable="YES"
 mta_type="sendmail"
 mta_profiles="incoming outgoing submitqueue"
 mta_incoming_flags="-L sm-mta-in -bd -OPrivacyOptions=noetrn -OQueueDirectory=/
var/spool/mqueue.in -ODeliveryMode=queueonly"
 mta_incoming_pidfile="/var/run/sendmail_in.pid"
 mta_incoming_configfile="/etc/mail/sendmail.cf"
 mta_outgoing_flags="-L sm-mta-out -q15m"
 mta_outgoing_pidfile="/var/run/sendmail_out.pid"
 mta_outgoing_configfile="/etc/mail/sendmail.cf"
 mta_submitqueue_flags="-L sm-msp-queue -Ac -q15m"
 mta_submitqueue_pidfile="/var/spool/clientmqueue/sm-client.pid"
 mta_submitqueue_configfile="/etc/mail/submit.cf"

將Sendmail前的#去掉,存檔退出。


4. 修改MailScanner.conf:
root@tea:/usr/local/etc/rc.d # vi /usr/local/etc/MailScanner/MailScanner.conf

%org-name% = Company
%org-long-name% = Company, Inc.
%web-site% = www.company.com
Max Children=5
Virus Scaning=Yes
Virus Scanners = clamav
Notify Senders = no
use SpamAssassin=yes

原則上使用default即可。

 

5. 修改rc.conf:
root@tea:/usr/local/etc/rc.d # vi /etc/rc.conf
# -- MailScanner Settings -- #
sendmail_enable="No"
spamd_enable="Yes"
clamav_clamd_enable="Yes"
clamav_freshclam_enable="YES"
mailscanner_enable="Yes"
mailscanner_configfile="/usr/local/etc/MailScanner/MailScanner.conf"
mailscanner_pidfile="/var/run/MailScanner.pid"

6. 修改/etc/mail下的檔案:

a. access:
root@tea:/etc/mail # vi /etc/mail/access
#admin@ns2.com          RELAY
aaa@ns2.com            RELAY
........................

ns2.com           discard

存檔退出。

 

b. Mailtable: 千萬要記得寫啊!!換機器名字這個檔案也要重跑喔!
root@tea:/etc/mail # vi mailertable
ns2.com          smtp:[192.168.1.3]    //指名要轉寄的內部mail server,如果沒有要做這一段這個不用設定。

存檔退出。

 

c. relay-domain
root@tea:/etc/mail # vi relay-domain
ns2.com

存檔退出。

 

7. 重編/etc/mail/的設定:

root@tea:/etc/mail # make
cp freebsd.mc tea.ns2.com.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 tea.ns2.com.mc > tea.ns2.com.cf
cp freebsd.submit.mc tea.ns2.com.submit.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 tea.ns2.com.submit.mc > tea.ns2.com.submit.cf
/usr/sbin/makemap hash mailertable.db < mailertable
chmod 0640 mailertable.db
/usr/sbin/makemap hash access.db < access
chmod 0640 access.db
root@tea:/etc/mail #


做完以後,在/etc/mail下有這些檔案:

root@tea:/etc/mail # ls
Makefile                        mailer.conf
README                          mailertable
access                          mailertable.db
access.db                       mailertable.sample
access.sample                   relay-domain
aliases                         sendmail.cf
aliases.db                      submit.cf
certs                           tea.ns2.com.cf
freebsd.cf                      tea.ns2.com.mc
freebsd.mc                      tea.ns2.com.submit.cf
freebsd.submit.cf               tea.ns2.com.submit.mc
freebsd.submit.mc               virtusertable.sample
helpfile

8. 啟動MTA、MailScanner和ClamAV

root@tea:/etc/mail # killall sendmail    <<<停掉可能在執行的sendmail
No matching processes were found

root@tea:/etc/mail # /usr/local/etc/rc.d/mta start     <<<啟動mta
===> mta profile: incoming
Starting mta.
===> mta profile: outgoing
Starting mta.
===> mta profile: submitqueue
Starting mta.

 

root@tea:/etc/mail # /usr/local/etc/rc.d/clamav-freshclam start    <<<啟動ClamAV
Starting clamav_freshclam.

 

root@tea:/etc/mail # /usr/local/etc/rc.d/mailscanner start     <<<啟動mailscanner
Starting mailscanner.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/CustomConfig.pm line 749.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/GenericSpam.pm line 39.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/RBLs.pm line 39.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/MCP.pm line 40.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/SA.pm line 39.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/CustomConfig.pm line 749.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/GenericSpam.pm line 39.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/RBLs.pm line 39.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/MCP.pm line 40.
Parameterless "use IO" deprecated at /usr/local/lib/MailScanner/MailScanner/SA.pm line 39.

↑以上錯誤據說將Perl改成舊版就ok了。但如果將Perl改成舊版,會導致MailScanner有重大錯誤:

root@tea:/usr/ports/lang/perl5.14 # /usr/local/etc/rc.d/mailscanner start
Starting mailscanner.
Can't locate Filesys/Df.pm in @INC (@INC contains: /usr/local/lib/MailScanner /usr/local/lib/MailScanner /usr/local/lib/perl5/site_perl/5.14/mach /usr/local/lib/perl5/site_perl/5.14 /usr/local/lib/perl5/5.14/mach /usr/local/lib/perl5/5.14 /usr/local/lib/perl5/5.14/BSDPAN) at /usr/local/sbin/mailscanner line 91.
BEGIN failed--compilation aborted at /usr/local/sbin/mailscanner line 91.
/usr/local/etc/rc.d/mailscanner: WARNING: failed to start mailscanner
↑如果是這個問題,MailScanner根本沒有執行。

 

目前只好暫時先這樣使用,看看是不是只是一個bug。

, , ,

貓熊麗麗 發表在 痞客邦 PIXNET 留言(0) 人氣()