一、先卸载sendmain
[root@ser ~]# yum –y 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.xt.com
mydomain = xt.com
myorigin = xt.com
inet_interfaces = all
mynetworks = 192.168.1.0/24
relay_domains = xt.com, $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain,
www.$mydomain
,
ftp.$mydomain
重启 postfix 服务
[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 的配置文件中,添加以下内容,使其支持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.xt.com 25 (提前做好bind解析或者改hosts)
Trying 192.168.1.2...
Connected to mail.yjw.com (192.168.1.2).
Escape character is '^]'.
220 mail.xt.com ESMTP Postfix
EHLO 163.com
250-mail.xt.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 #出现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
出现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
[email protected]
ServerName mail.xt.com:80
AddHandler cgi-script .cgi .pl
七、登陆openwebmail.
在IE 中输入 mail.xt.com/cgi-bin/openwebmail/openwebmail.pl, 这个地址是不是很长,那么我们来点短点的
在 httpd的 配置文件中添加 下面 内容:
ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl
这样在IE 中直接输入
mail.xt.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
先检查您的系统内是否已经安装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文件,主要说明修改的关键部分:
%org-name% = yjw.com
%org-long-name% = xt
web-site% = mail.xt.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
设置中文邮件过滤规则
[root@ser ~]# wget -N -P
http://www.ccert.edn.cn/spam/sa/Chiese_rules.cf
/usr/share/spamassassin
使用计划任务来更新规则
[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, 测试 收信,发信是否正常
[root@ser ~]# useradd tom
[root@ser ~]# passwd tom
tom
tom
[root@ser ~]# useradd yjw
[root@ser ~]# passwd yjw
020304
020304
我在系统中测试收信发信是没有问题的,可以给163.com等域发邮件,系统内的用户对发是没有问题的。至此,一个多功能邮件就搭建完成
参考资料:
1、实验环境:
网络域名:test.org
DNS主机名称:mail.test.org
DNS主机IP地址:192.168.10.1
邮件主机名称:mail.test.org
邮件主机IP地址:192.168.10.1
操作系统:RedHat Enterprise Server 5
防火墙:打开相应端口
2、DNS服务器的配置:略
3、安装软件:
###################################################
rpm -ivh bind- 9.3.3 -7.el5.i386.rpm
rpm -ivh bind-devel-9.3.3-7.el5.i386.rpm
rpm -ivh bind-chroot-9.3.3-7.el5.i386.rpm
rpm -ivh caching-nameserver-9.3.3-7.el5.i386.rpm
rpm -qa |grep sendmail
rpm -e --nodeps sendmail-8.13.8-2.el5
rpm -qa |grep sendmail
rpm -ivh postfix-2.3.3-2.i386.rpm
rpm -ivh postfix-pflogsumm-2.3.3-2.i386.rpm
rpm -ivh httpd-2.2.3-6.el5.i386.rpm
rpm -ivh httpd-devel-2.2.3-6.el5.i386.rpm
rpm -ivh httpd-manual-2.2.3-6.el5.i386.rpm
rpm -ivh cyrus-sasl-2.1.22-4.i386.rpm
rpm -ivh perl-Carp-Clan-5.3-1.2.1.noarch.rpm
rpm -ivh perl-Bit-Vector-6.4-2.2.2.1.i386.rpm
rpm -ivh perl-Date-Calc-5.4-1.2.2.1.i386.rpm
rpm -ivh perl-Compress-Zlib-1.42-1.fc6.i386.rpm
rpm -ivh perl-5.8.8-10.i386.rpm
rpm -ivh perl-suidperl-5.8.8-10.i386.rpm
rpm -ivh perl-DBI-1.52-1.fc6.i386.rpm
rpm -ivh perl-CGI-SpeedyCGI-2.22-1.2.el5.rf.i386.rpm
rpm -ivh perl-Text-Iconv-1.4-1.2.el5.rf.i386.rpm
rpm -ivh mysql-5.0.22-2.1.i386.rpm
rpm -ivh mysql-devel-5.0.22-2.1.i386.rpm
rpm -ivh dovecot-1.0-1.2.rc15.el5.i386.rpm
rpm -ivh openwebmail-2.51-1.i386.rpm
#####################################################
4、查询安装完成后的结果
rpm -qa |grep postfix
postfix-2.3.3-2.el5.rf.i386.rpm
postfix-pflogsumm-2.3.3-2.el5.rf.i386.rpm
rpm -qa |grep cyrus
cyrus-sasl-lib-2.1.22-4
cyrus-sasl-plain-2.1.22-4
cyrus-sasl-devel-2.1.22-4
cyrus-sasl-2.1.22-4
rpm -qa |grep dovecot
dovecot-1.0-1.2.rc15.el5
rpm -qa |grep httpd
httpd-2.2.3-6.el5
httpd-manual-2.2.3-6.el5
rpm -qa |grep perl
perl-suidperl-5.8.8-10
perl-CGI-SpeedyCGI-2.22-1.2.el5.rf
perl-Compress-Zlib-1.42-1.fc6
perl-Bit-Vector-6.4-2.2.2.1
perl-URI-1.35-3
perl-libwww-perl-5.805-1.1.1
perl-SGMLSpm-1.03ii-16.2.1
perl-Date-Calc-5.4-1.2.2.1
perl-String-CRC32-1.4-2.fc6
perl-HTML-Parser-3.55-1.fc6
perl-5.8.8-10
perl-HTML-Tagset-3.10-2.1.1
perl-Carp-Clan-5.3-1.2.1
perl-DBI-1.52-1.fc6
perl-Text-Iconv-1.4-1.2.el5.rf
perl-CGI-SpeedyCGI-2.22-1.2.el5.rf.i386.rpm
perl-Text-Iconv-1.4-1.2.el5.rf.i386.rpm
rpm -qa |grep mysql
mysql-5.0.22-2.1
mysql-devel-5.0.22-2.1
rpm -qa |grep openwebmail
openwebmail-2.51-1.i386.rpm
5、启动postfix + dovecot服务过程:
# service postfix start
Starting postfix: [ 确定 ]
# service dovecot start
启动 Dovecot Imap: [ 确定 ]
6、修改/etc/dovecot.conf文件:
#protocols = imap imap3
更改为:
protocols = imap imap3 pop3 pop3s (启动imap imap3 pop3 pop3s功能)
# service dovecot restart(重新启动dovecot服务)
停止 Dovecot Imap: [ 确定 ]
启动 Dovecot Imap: [ 确定 ]
7、修改/etc/postfix/main.cf文件:
#myhostname = host.domain.tld
更改为:
myhostname = mail.test.org (指定运行Postfix邮件系统的主机名称)
#mydomain = domain.tld
更改为:
mydomain = test.org (指定Postfix邮件系统使用的域名)
#myorigin = $mydomain
更改为:
myorigin = test.org (指定发件人所在的域名)
#inet_interfaces = all
更改为:
Inet_interfaces =all (指定Postfix邮件系统监视的网络接口)
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain
更改为:
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain(指定Postfix接收邮件时收件人的域名)
#mynetworks = host
更改为:
mynetworks = host (指定您所在的网络地址192.168.10.0/24)
# service postfix restart (重新启动postfix服务)
Shutting down postfix: [ 确定 ]
Starting postfix: [ 确定 ]
8、端口测试:
# telnet mail.test.org 25 (测试25端口)Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.easy.com ESMTP Postfix
quit
221 Bye
Connection closed by foreign host.
# telnet mail.test.org 110 (测试110端口)Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK dovecot ready.
quit
+OK Logging out
Connection closed by foreign host.
9、配置openwebmail:
# service httpd restart (启动httpd服务)
停止 httpd: [ 确定 ]
启动 httpd: [ 确定 ]
# cd /var/www/cgi-bin/openwebmail/
# ./openwebmail-tool.pl --init
Please change './etc/dbm.conf' from
dbm_ext .db
dbmopen_ext none
dbmopen_haslock no
to
dbm_ext .db
dbmopen_ext .db
dbmopen_haslock no
And execute './openwebmail-tool.pl --init' again!
ps: If you are running openwebmail in persistent mode,
don't forget to 'touch openwebmail*.pl', so speedycgi
will reload all scripts, modules and conf files in --init.
10、修改 /var/www/cgi-bin/openwebmail/etc/openwebmail.conf 文件:
domainnames auto
更改为:
domainnames test.org (更改为自己定义的域名)
default_language en
更改为:
default_language zh_CN.GB2312 (更改为简体中文版介面)
default_iconset Cool3D.Englist
更改为:
default_iconset Cool3D.Chinese.Simplified (更改为中文3D按键)
11、修改/var/www/cgi-bin/openwebmail/etc/defaults/openwebmail.conf文件:
smtpserver 127.0.0.1
更改为:
smtpserver 192.168.10.1 (更改smtp服务器的地址)
authpop3_server localhost
更改为:
authpop3_server 192.168.10.1 (更改pop3服务器的地址)
12、修改/var/www/cgi-bin/openwebmail/etc/defaults/dbm.conf文件:
dbmopen_ext none
更改为:
dbmopen_ext .db
dbmopen_haslock no
更改为:
dbmopen_haslock yes
smtpserver 192.168.10.1 (添加smtp服务器的地址)
13、继续运行openwebmail-tool.pl文件:
# ./openwebmail-tool.pl --init
creating db /var/www/cgi-bin/openwebmail/etc/maps/b 2g ...done.
creating db /var/www/cgi-bin/openwebmail/etc/maps/g2b ...done.
creating db /var/www/cgi-bin/openwebmail/etc/maps/lunar ...done.
Welcome to the Open WebMail!
This program is going to send a short message back to the developer,
so we could have the idea that who is installing and how many sites are
using this software, the content to be sent is:
OS: Linux 2.6.9-11.EL i686
Perl: 5.008005
WebMail: Open WebMail 2.51 20050228
Send the site report?(Y/n) y (输入y,然后按回车键)
sending report...
Thank you.
14、增加用户发送电子邮:
增加本地用户:
# useradd user1
# useradd user2
# useradd user3
设置本地yer用户的密码
# passwd user1
Changing password for user yer.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
# passwd user2
Changing password for user fandy.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
# passwd user3
Changing password for user biao.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
15、测试webmail方式收发电子邮件:
在ie中输入以下地址:
http://mail.easy.com/cgi-bin/openwebmail/openwebmail.pl
试验成功。
本文出自 “____�N.�r^随记” 博客,转载请与作者联系!