平台centos6.5 x86_64最小化安装
一,系统设置
1,echo 'yourserverIP localhost' > /etc/hosts
2,sed -i 's/HOSTNAME=*/HOSTNAME=yourdomain.com/g' /etc/sysconfig/network
3,命令host -t mx yourdomain.com确认MX记录生效
4,修改时区 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
clock -w #同步BIOS时间
二,安装postfix
yum update -y
rpm -q postfix dovecot sendmail dovecot和sendmail默认没有安装
yum install -y dovecot
vi /etc/postfix/main.cf
myhostname = mail.yourdomain.com 指email服务器的域名
mydomain = yourdomain.com 指系统的主机名称
myorigin = $mydomain 指定本地发送邮件中来源和传递显示的域名
inet_interfaces = all 设置网络接口以便Postfix能接收到邮件
mynetworks = 127.0.0.1/8 指定受信任SMTP的列表
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relay_domains = $mydestination 系统传递邮件的目的域名列表
home_mailbox = Maildir/ 设置邮箱路径与用户目录
smtpd_sasl_type = dovecot 启用dovecot-sasl认证
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes 启用sasl授权
smtpd_sasl_local_domain = $myhostname sasl的本地域
smtpd_sasl_security_options = noanonymous 不允许匿名登录
broken_sasl_auth_clients = yes 客户端兼容支持
smtpd_recipient_restrictions =permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_client_restrictions = permit_sasl_authenticated
message_size_limit = 102400000
mailbox_size_limit = 204800000
chkconfig postfix on
service postfix restart
查看具体有效配置项参数
postconf -n
测试一
yum install -y mailx
mail -s 'hello' [email protected] < /etc/hosts
测试二
yum install -y telnet
telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mail.yourdomain.com ESMTP Postfix
输入ehlo yourserverIP
退出quit
三,配置dovecot
1,vi /etc/dovecot/dovecot.conf 支持pop3和imap协议
protocols = imap pop3 lmtp
listen = *
2,vi /etc/dovecot/conf.d/10-auth.conf 指明创建的Unix socket使用的权限,以及用户和组属性
disable_plaintext_auth = no 允许密码明文认证
auth_mechanisms = plain login
3,vi /etc/dovecot/conf.d/10-mail.conf 设置邮箱文件存放位置
mail_location = maildir:~/Maildir
4,vi /etc/dovecot/conf.d/10-master.conf 设置dovecot-sasl认证
# commented on these line:
#unix_listener auth-userdb {
#mode = 0600
#user =
#group =
#}
# change or setup on these line:
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
5,vi /etc/dovecot/conf.d/10-ssl.conf 关闭ssl加密(这里为了便于测试)
修改为ssl = no
6,vi /etc/dovecot/conf.d/20-pop3.conf
# uncomment on these line:
pop3_uidl_format = %08Xu%08Xv
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
chkconfig dovecot on
service dovecot start
查看具体有效配置项参数
dovecot -n
telnet localhost 110
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready. 服务已ok
quit 退出
+OK Logging out
Connection closed by foreign host.
四,创建账户
Postfix默认用系统用户作为邮件账号,需要添加Linux系统用户账号相互收发邮件测试
groupadd mailusers
adduser -g mailusers -s /sbin/nologin test
passwd test
mkdir -p /home/test/Maildir
chown test:mailusers /home/test/Maildir
chmod -R 700 /home/test/Maildir
下载Foxmail测试该账号收发邮件
http://www.linuxde.net/2013/07/14774.html