用于搭建的服务器信息
虚拟机 Centos 6.9 64位
Postfix-2.8.12.tar.gz Postfix MTA(邮件传输代理)
Dovecot-2.1.8.tar.gz IMAP 和 POP3 邮件服务器 //没有使用foxmail等客户端测试
以下这2个没使用到(备忘)。
Postfixadmin-2.3.5.tar.gz 采用PHP编写的开源WEB邮箱及域名账号管理工具
Roundcubemail-0.8.1.tar.gz 采用PHP编写的开源IMAP邮件WEB客户端
安装过程
1.安装Postfix
yum -y install postfix
安装完成还需要替换系统自带的sendmail:
-
rpm -e sendmail
-
或者
-
yum remove sendmail
修改MTA(默认邮件传输代理)
-
alternatives --config mta
然后直接回车即可。
检查一下是不是已经设置成功了。
-
alternatives --display mta
第一行可以看到mta的状态。 例如:mat - status is manual.
2.安装Dovecot
yum -y install dovecot
3.配置Postfix
编辑/etc/postfix/main.cf
,可以下载下来修改,也可以使用vi进行编辑:
vi /etc/postfix/main.cf
修改如下:
# 75行: 取消注释,设置hostname
myhostname = mail.lomu.me
# 83行: 取消注释,设置域名
mydomain = lomu.me
# 99行: 取消注释
myorigin = $mydomain
# 116行: 修改
inet_interfaces = all
# 119行: 推荐ipv4,如果支持ipv6,则可以为all
inet_protocols = ipv4
# 164行: 添加
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# 264行: 取消注释,指定内网和本地的IP地址范围
mynetworks = 127.0.0.0/8, 10.0.0.0/24
# 419行: 取消注释,邮件保存目录
home_mailbox = Maildir/
# 571行: 添加
smtpd_banner = $myhostname ESMTP
# 添加到最后
# 规定邮件最大尺寸为10M
message_size_limit = 10485760
# 规定收件箱最大容量为1G
mailbox_size_limit = 1073741824
# SMTP认证
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
改好了之后使用/etc/rc.d/init.d/postfix start
开启postfix,使用chkconfig postfix on
将postfix开机启动。
4.配置Dovecot
修改如下:
[root@mail ~]# vi /etc/dovecot/dovecot.conf
# 26行: 如果不使用IPv6,请修改为*
listen = *
[root@mail ~]# vi /etc/dovecot/conf.d/10-auth.conf
# 9行: 取消注释并修改
disable_plaintext_auth = no
# 97行: 添加
auth_mechanisms = plain login
[root@mail ~]# vi /etc/dovecot/conf.d/10-mail.conf
# 30行: 取消注释并添加
mail_location = maildir:~/Maildir
[root@mail ~]# vi /etc/dovecot/conf.d/10-master.conf
# 88-90行: 取消注释并添加
# Postfix smtp验证
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
[root@mail ~]# /etc/rc.d/init.d/dovecot start
Starting Dovecot Imap: [ OK ]
[root@mail ~]# chkconfig dovecot on
到这里,我们的邮件服务器就已经搭建成功了
在此 使用了 HOSTS设置了域名解析。没有使用DNS SERVER
vi /etc/hosts
IP 域名 主机号
格式
测试:
$usersadd admin
$usersadd gamers
mail -s "hello" gamer@域名 //回车后是内容
这里是内容。。。
Ctrl +D 编辑完成邮件内容并发送
EOT //说明pass