本文共 2035 字,大约阅读时间需要 6 分钟。
在阿里云CentOS 6.x环境中安装邮件传输代理Postfix:
yum -y install postfix
安装完成后,需要替换系统自带的sendmail:
rpm -e sendmail
或者使用Yum移除sendmail:
yum remove sendmail
设置MTA(默认邮件传输代理):
alternatives --config mta
按照提示逐步选择Postfix。
检查MTA配置是否成功:
alternatives --display mta
观察输出,确认第一行显示mta状态为“manual”。
安装 Dovecot:
yum -y install dovecot
编辑 /etc/postfix/main.cf:
vi /etc/postfix/main.cf
修改配置:
取消注释,设置hostname:
myhostname = mail.ramuel.com
取消注释,设置domain:
mydomain = ramuel.com
取消注释,设置origin:
myorigin = $mydomain
修改inet_interfaces为all:
inet_interfaces = all
推荐设置inet_protocols为ipv4:
inet_protocols = ipv4
添加mydestination:
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
设置内网和本地IP地址范围:
mynetworks = 127.0.0.0/8, 10.0.0.0/24
设置邮件保存目录:
home_mailbox = Maildir/
添加SMTP banner:
smtpd_banner = $myhostname ESMTP
设置邮件大小限制:
message_size_limit = 10485760
收件箱最大容量:
mailbox_size_limit = 1073741824
SMTP认证配置:
smtpd_sasl_type = dovecotsmtpd_sasl_path = private/authsmtpd_sasl_auth_enable = yessmtpd_sasl_security_options = noanonymoussmtpd_sasl_local_domain = $myhostname
设置接收限制:
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject
启动Postfix并设置开机启动:
/etc/rc.d/init.d/postfix startchkconfig postfix on
编辑Dovecot配置文件:
vi /etc/dovecot/dovecot.conf
如果不使用IPv6,修改listen项:
listen = *
编辑 10-auth.conf:
vi /etc/dovecot/conf.d/10-auth.conf
取消注释并设置:
disable_plaintext_auth = noauth_mechanisms = plain login
编辑 10-mail.conf:
vi /etc/dovecot/conf.d/10-mail.conf
取消注释并设置:
mail_location = maildir:~/Maildir
编辑 10-master.conf:
vi /etc/dovecot/conf.d/10-master.conf
取消注释并添加:
unix_listener /var/spool/postfix/private/auth { mode = 0666 user = postfix group = postfix} 启动Dovecot并设置开机启动:
/etc/rc.d/init.d/dovecot startchkconfig dovecot on
创建用户并设置密码:
useradd adminpasswd admin1234
登录Foxmail等第三方邮件客户端,使用root@domain.com账号登录。
以上步骤完成后,您已成功搭建阿里云CentOS 6.x的邮件服务器。
转载地址:http://ajxfk.baihongyu.com/