CentOS+postfix+dovecot邮件服务器配置。
相关环境:
Centos6.2 有公网IP(省了映射了),域名MX记录解析已经完成,要求能让客户端使用POP3/IMAP收发邮件。
开工,安装软件先:
yum install postfix , dovecot
修改下postfix的配置文件main.cf,修改前备份是个好习惯哦。
cp /etc/postfix/main.cf main.cf.bak
vi /etc/postfix/main.cf
我爱死Yum了,有了Yum腰不酸、腿不疼,安装软件不费劲。
需要修改的内容如下:
myhostname = //主机名(mail.test.com)
mydomain = //你的域名(test.com)
myorigin = $mydomain //去掉前面#号就可以
inet_interfaces = all //最新版默认就是这个,如果你下载的版本前面带#,请去掉
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain //添加一个$mydomain
mynetworks = 127.0.0.0/8, 192.168.6.0/24 //根据你的情况配置网段
relay_domains = $mydestination //默认就是这样,如果你也是的话不用修改
home_mailbox = Maildir/ //去掉前面#
其实配置完这些这台服务器已经可以收发邮件了,我们先关闭iptables和selinux测试下。
service postfix start
mail -s "This ia the first test mail" test@gmail.com</etc/hosts
在其它电脑上一看,正常收到邮件,都不用telnet下25端口了。
当然这离我们的要求还有些距离,我们还要配置下pop3和imap。
编辑/etc/postfix/main.cf,在最下方增加如下代码启用sasl认证。
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
broken_sasl_auth_clients = yes
对于dovecot的配置文件dovecot.conf其实不用做其它修改,只需加入以下代码即可:
auth default {
socket listen {
client {
path = /var/spool/postfix/private/auth
mode = 0660
user = postfix
group = postfix
}
}
mechanisms = plain login
}我看了下网上的一些教程,都好像要修改很多东西似的,其实不用,很多都不重要,一个比较重要的就是要在protocols项的后面加上pop3,其实这个现在的版本官方配置就已经是这样了。
chkconfig dovecot on
chkconfig postfix on
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.