postfix dovecoty邮件服务器的搭建与配置
2009RoseData钱辉[邮件服务器(postfix dovecot) 的安装与配置 ] 此文档是根据张天博和何国宾的文档总结而来。MailKeeper 组精心打造
2009
RoseData
钱辉
[邮件服务器(postfix dovecot) 的安装与配置 ] 此文档是根据张天博和何国宾的文档总结而来。
MailKeeper 组精心打造
,一、安装邮件服务器相关软件包 postfix 发信服务器;dovecot 收信服务器
# rpm -ivh postfix-2.1.5-2.3.RHEL4.1.i386.rpm # rpm -ivh dovecot-0.99.11-2.EL4.1.i386.rpm (建议:因为rpm 包的依赖很多,所以建议在安装系统的时候就把postfix 安装起。顺便建议不要开启防火墙!)
二、启动服务
启动dovecot 服务:#service dovecot start
启动postfix 服务:#service postfix start (注意:
1. 如果postfix 服务启动不了,并且无任何提
示,则要先停止sendmail 服务“service
sendmail stop”,然后再启动postfix 服
务,最好就是不要安装sendmail 或者是删
除sendmail 。
2. 如果出现“listen(995):Address already
in use”的错误报告,则可以使用命令“lsof
–i :995”来查看使用995的程序,例如
MailKeeper 组精心打造
,发现是rpc.statd ,则可以用“service
nfslock stop”来停止。)
三、修改dovecot 配置文件:/etc/dovecot.conf
protocols = imap imaps pop3 pop3s
四、修改postfix 配置文件:/etc/postfix/main.cf
myhostname =服务器的主机名(用hostname 查看,例如:mail.mkdovecot.com )
mydomain =服务器的域名(就是即将用作服务器的域名,例如:mkdovecot.com )
myorigin = $mydomain
inet_interfaces = all
MailKeeper 组精心打造
,mydestination = $myhostname,
localhost.$mydomain, localhost,$mydomain
mynetworks = 服务器的ip 地址
保存退出
五、重启服务:
# service postfix restart
# service dovecot restart
六、测试服务器(关掉防火墙)
# telnet 主机名(或者是服务器IP 、127.0.0.1) 25
# telnet主机名(或者是服务器IP 、127.0.0.1) 110
查看上面是否显示成功
MailKeeper 组精心打造
,到此此服务器已可以正常收发信件
七、配置安全证书
1) 建立服务器密钥
# cd /etc/httpd/conf
# rm ssl.*/server.*
#mkdir ssl.key ssl.csr ssl.crt
# /usr/bin/openssl genrsa -des3 1024 > /etc/httpd/conf/ssl.key/server.key
# openssl rsa -in ssl.key/server.key -out ssl.key/server.key
2) 建立服务器公钥
# /usr/bin/openssl req -new -key
MailKeeper 组精心打造
,/etc/httpd/conf/ssl.key/server.key -out
/etc/httpd/conf/ssl.csr/server.csr
3) 建立服务证书
# openssl x509 -in ssl.csr/server.csr -out
ssl.crt/server.crt -req -signkey ssl.key/server.key -days 365
4) 配置ssl
# Vi /etc/httpd/conf.d/ssl.conf 把DocumentRoot “/var/www/html” 前注释去掉
5) 重启服务
# Service httpd restart
6) 测试apache 和安全认证。
在网址处输入:https ://localhost或者https://127.0.0.1
MailKeeper 组精心打造
,八、配置postfix
1) 编辑postfix 的main.cf
# Vi /etc/postfix/main.cf 在末尾添加:
smtpd_use_tls = yes
smtpd_tls_session_cache_database =
btree:/etc/postfix/smtpd_scache
smtpd_tls_cert_file = /etc/httpd/conf/ssl.crt/server.crt Dovecot postfix
smtpd_tls_key_file = /etc/httpd/conf/ssl.key/server.key
smtpd_sasl_quth_enable = yes
?smtpd_delay_reject = yes
?smtpd_recipient_restrictions = permit_mynetworks
Permit_sasl_authenticated = permit_auth_destination reject
Broken_sasl_auth_clients = yes
MailKeeper 组精心打造
,Smtpd_sasl_security_options = noanonymous
2) 编辑master.cf
# Vi /etc/postfix/master.cf
去掉注释: smtp inet n - n - - smtpd
-o smtpd_tls_wrappermode = yes
–o smtpd_sasl_auth_enable = yes
3) 编辑 dovecot.conf
# Vi /etc/dovecot.conf
将protocols = imap pop3 改成 protocols = imap imaps pop3 pop3s 并且去掉注释。
去掉ssl_disable = no的注释使其生效。
修改ssl_cert_file = /etc/httpd/conf/ssl.crt/server.crt
ssl_key_file = /etc/httpd/conf/ssl.key/server.key
九、开启saslauthd 服务
#service saslauthd start(开启此服务为能通过“smtp 服
MailKeeper 组精心打造
,务器需要身份验证”)
重启服务和网络。(dovecot ,postfix ,networks )
十、windows 客户端用Outlook Express 测试
Thank You !!
MailKeeper 组精心打造