- 論壇徽章:
- 0
|
實驗環(huán)境 VM 6.0 ,RHEL 5.0 ,內(nèi)核 2.6.18,本地YUN源
一、先卸載sendmain
[root@ser ~]# yum remove sendmail
二、安裝postfix ,dovecot,cyrus-sasl
[root@ser ~]# yum -y install postfix
[root@ser ~]# yum -y install dovecot
[root@ser ~]# yum -y install cyrus-sasl
四、 修改postfix的配置文件
[root@ser ~]# vim /etc/postfix/main.cf
myhostname = mail.yjw.com
mydomain = yjw.com
myorigin = yjw.com
inet_interfaces =all
mynetworks = 192.168.1.0/24
relay_domains = yjw.com, $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain,
www.$mydomain
,
ftp.$mydomain
重啟 postfix 服務(wù)
[root@ser ~]# service postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
[root@ser ~]# chkconfig postfix on
[root@ser ~]# chkconfig dovecot on
修改dovecot的配置文件
vim /etc/dovecot.conf
protocols = imap imaps pop3 pop3s
listen = *
在iptables 里開放25,110,143端口
[root@ser ~]# vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT
重啟iptables
[root@ser ~]# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]ntrack_ftp
[root@ser ~]# yum -y install cyrus-sasl
[root@ser ~]# chkconfig saslauthd on
修改 /etc/sysconfig/saslauthd
[root@ser ~]# vim /etc/sysconfig/saslauthd
# Directory in which to place saslauthd's listening socket, pid file, and so
# on. This directory must already exist.
SOCKETDIR=/var/run/saslauthd
# Mechanism to use when checking passwords. Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=shadow
# Additional flags to pass to saslauthd on the command line. See saslauthd(8)
# for the list of accepted flags.
FLAGS=
修改 /usr/lib/sasl2/smtpd.conf
[root@ser ~]# vim /usr/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd
測試 saslauthd
[root@ser ~]# service saslauthd restart
[root@ser ~]# testsaslautd -u yjw -p '020304'
0: OK "Success."
在postfix 的配置文件中,添加以下內(nèi)容,使其支持SMTP認證
[root@ser ~]# vim /etc/postfix/main.cf
message_size_limit = 1073741824 # 郵件的大小為10M
default_process_limit = 50
default_destination_concurrency_limit = 20
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_unauth_destination
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
測試 25端口
[root@ser ~]# telnet mail.yjw.com 25
Trying 192.168.1.2...
Connected to mail.yjw.com (192.168.1.2).
Escape character is '^]'.
220 mail.yjw.com ESMTP Postfix
EHLO 163.com
250-mail.yjw.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@ser ~]#
五、安裝openwebmail
[root@ser ~]# vim /etc/yum.repos.d/openwebmail.repo
[openwebmail]
## Thomas Chung
## 2008.05.29
name=Openwebmail for Fedora or Enterprise Linux
baseurl=http://openwebmail.org/openwebmail/download/redhat/rpm/release/
enabled=1
gpgcheck=1
gpgkey=http://openwebmail.org/openwebmail/download/redhat/rpm/release/RPM-GPG-KEY-openwebmail
#metadata_expire=0
若這樣安裝不成功,先安裝 perl-Text-Iconv-1.4-1.2.el4.rf.i386.rpm
[root@ser ~]# yum -y install openwebmail
[root@ser ~]# cd /var/www/cgi-bin/openwebmail/
[root@ser openwebmail]# ./openwebmail-tool.pl --init #出現(xiàn)Y/N時 ,按N.
修改openwebmail 的一些配置文件
[root@ser etc]# vim dbm.conf
dbm_ext .db
dbmopen_ext .db
dbmopen_haslock no
[root@ser etc]]# cd defaults/
[root@ser defaults]# vim dbm.conf
dbm_ext .db
dbmopen_ext .db
dbmopen_haslock yes
smtpserver 192.168.1.2
[root@ser defaults]# vim openwebmail.conf
domainnames yjw.com
smtpserver 192.168.1.2
authpop3_server 192.168.1.2
再次初始化openwebmail
[root@ser defaults]# cd ../../openwebmail-tool.pl --init
出現(xiàn)Y/N 時,按Y。
六、安裝httpd
[root@ser ~]# yum - y install httpd
[root@ser ~]# chkconfig httpd on
[root@ser ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@ser ~]# vim /etc/httpd/conf/httpd.conf
ServerAdmin
root@yjw.com
ServerName mail.yjw.com:80
AddHandler cgi-script .cgi .pl
七、登陸openwebmail.
在IE 中輸入 mail.yjw.com/cgi-bin/openwebmail/openwebmail.pl, 這個地址是不是很長,那么我們來點短點的
在 httpd的 配置文件中添加 下面 內(nèi)容:
ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl
這樣在IE 中直接輸入
mail.yjw.com/mail
八、安裝反垃圾郵件軟件,MailScanner
到MailScanner .org 上下載MailScanner-4.75.11-1.rpm.tar.gz
[root@ser ~]# tar zxvf MailScanner-4.75.11-1.rpm.tar.gz
[root@ser ~]# cd MailScanner-4.75.11
[root@ser MailScanner-4.75.11-1]# ./install.sh # 安裝
安裝 spamassassin
先檢查您的系統(tǒng)內(nèi)是否已經(jīng)安裝SpamAssassin軟件包。在文本終端中輸入:
[root@ser ~]# rpm -qa | grep spamassassin
spamassassin-3.1.9-1.el5
下載Mail-SpamAssassin-3.2.5.tar.gz
[root@ser ~]#tar -zxvf Mail-SpamAssassin-3.2.5.tar.gz
[root@ser ~]# cd Mail-SpamAssassin-3.2.5
[root@ser ~]# perl Makefile.PL
[root@ser ~]# make
[root@ser ~]# make install
打開/etc/MailScanner/目錄中的MailScanner.conf文件,主要說明修改的關(guān)鍵部分:
%org-name% = yjw.com
%org-long-name% = yjw
web-site% = mail.yjw.com
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Incoming Work Group = postfix
Quarantine User = postfix
Quarantine Group = postfix
Always Include SpamAssassin Report = yes
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
SpamAssassin Install Prefix = /usr/bin
Log Speed = yes
Log Spam = yes
Log Silent Viruses = yes
Phishing Modify Subject = yes
更改incoming,quarantine 兩個2個目錄
[root@ser ~]# service spamassassin restart
[root@ser ~]# service spamassassin on
[root@ser ~]# service MailScanner restart
[root@ser ~]# service MailScanner on
[root@ser ~]# chown -R postfix:postfix /var/spool/MailScanner/*
[root@ser ~]# cd /var/spool/MailScanner/
[root@ser MailScanner]# ll
drwxr-xr-x 4 postfix postfix 4096 Apr 30 16:56 incoming
drwxr-xr-x 3 postfix postfix 4096 Apr 29 19:10 quarantine
drwx------ 2 postfix postfix 4096 Apr 30 15:58 spamassassin
在/etc/postfix/header_checks 中增加一句話:
[root@ser ~]# vi /etc/postfix/header_checks
/^Received:/ HOLD
設(shè)置中文郵件過濾規(guī)則
[root@ser ~]# wget -N -P
http://www.ccert.edn.cn/spam/sa/Chiese_rules.cf
/usr/share/spamassassin
使用計劃任務(wù)來更新規(guī)則
[root@ser ~]# crontab -e
0 0 1 * * wget - N -P /usr/share/spamassassin
http://www.ccert.edu.cn/spam/sa/Chiness_rules.cf
; /etc/init.d/spamassassin restart
九、登陸openwebmail, 測試 收信,發(fā)信是否正常
[root@ser ~]# useradd tom
[root@ser ~]# passwd tom
tom
tom
[root@ser ~]# useradd yjw
[root@ser ~]# passwd yjw
020304
020304
我在系統(tǒng)中測試收信發(fā)信是沒有問題的,可以給163.com等域發(fā)郵件,系統(tǒng)內(nèi)的用戶對發(fā)是沒有問題的。至此,一個多功能郵件就搭建完成。相關(guān)的文檔可以在 baidu ,google 上查找。
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u3/90685/showart_1915784.html |
|