Centos7下postfix+Dovecot+cyrus-sasl搭建个人局域网邮件服务器(测试使用)
1、环境准备,Centos 7 机器一台(选择vsphere环境下的一台虚拟机),虚拟机进行环境配置:
a):IP配置,最后能够访问Inetnet,主要能够访问yum源,也可配置可访问的局域网源;
b):配置防火墙规则,由于是测试使用,所以直接关闭firewalld服务
2、修改虚拟机的hostname和domain(测试过程中发现没啥用,大概了解下就可以)
3、安装、配置、启用postfix yum install postfix(一般OS都已经自带)
[aaa@qq.com ~]# vi /etc/postfix/main.cf
# line 75: uncomment and specify hostname
myhostname = linuxprobe.srv.world
# line 83: uncomment and specify domain name
mydomain = srv.world
# line 99: uncomment
myorigin = $mydomain
# line 116: change
inet_interfaces = all
# line 164: add
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# line 264: uncomment and specify your local network
mynetworks = 127.0.0.0/8, 10.0.0.0/24
# line 419: uncomment (use mailboxdir)
home_mailbox = mailbox/
# line 574: add
smtpd_banner = $myhostname ESMTP
# add follows to the end
# limit an email size for 10M
message_size_limit = 10485760
# limit a mailbox for 1G
mailbox_size_limit = 1073741824
# for SMTP-Auth
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
[aaa@qq.com ~]# systemctl restart postfix
[aaa@qq.com ~]# systemctl enable postfix
4、安装配置启动dovecot yum install dovecot[aaa@qq.com ~]# vi /etc/dovecot/dovecot.conf
# line 24: uncomment
protocols = imap pop3 lmtp
# line 30: uncomment and change ( if not use IPv6 )
listen = *
[aaa@qq.com ~]# vi /etc/dovecot/conf.d/10-auth.conf
# line 10: uncomment and change ( allow plain text auth )
disable_plaintext_auth = no
# line 100: add
auth_mechanisms = plain login
[aaa@qq.com ~]# vi /etc/dovecot/conf.d/10-mail.conf
# line 30: uncomment and add
mail_location = maildir:~/Maildir
[aaa@qq.com ~]# vi /etc/dovecot/conf.d/10-master.conf
# line 96-98: uncomment and add like follows
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
[aaa@qq.com ~]# vi /etc/dovecot/conf.d/10-ssl.conf
# line 8: change (not require SSL)
ssl = no
[aaa@qq.com ~]# systemctl start dovecot
[aaa@qq.com ~]# systemctl enable dovecot
5、安装配置启动sasl
yum install cyrus-sasl-*
vim /etc/sysconfig/saslauthd
MECH=shadow #指定以本地系统用户名认证
vim /usr/lib64/sas12/smtpd.conf //64位系统
vim /usr/lib/sas12/smtpd.conf //32位系统
smtpd.conf配置文件默认是没有的,vim编辑的同时创建
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level:3
6、验证,创建管理员账号和测试用户账号。添加到mailfox互相发邮件测试。注意在添加过程中,由于局域网没有域名等信息,所以直接填写的服务器IP地址(发现很多教程中,设置域名和MX那些太繁琐)
7、邮件信息统计pflogsumm
yum -y install postfix-perl-scripts
[aaa@qq.com ~]# perl /usr/sbin/pflogsumm -d today /var/log/maillog
Postfix log summaries for Oct 11
Grand Totals
------------
messages
2 received
2 delivered
0 forwarded
0 deferred
0 bounced
0 rejected (0%)
0 reject warnings
0 held
0 discarded (0%)
1928 bytes received
1928 bytes delivered
1 senders
1 sending hosts/domains
1 recipients
1 recipient hosts/domains
Per-Hour Traffic Summary
------------------------
time received delivered deferred bounced rejected
--------------------------------------------------------------------
0000-0100 0 0 0 0 0
0100-0200 0 0 0 0 0
0200-0300 0 0 0 0 0
0300-0400 0 0 0 0 0
0400-0500 0 0 0 0 0
0500-0600 0 0 0 0 0
0600-0700 0 0 0 0 0
0700-0800 0 0 0 0 0
0800-0900 0 0 0 0 0
0900-1000 0 0 0 0 0
1000-1100 0 0 0 0 0
1100-1200 0 0 0 0 0
1200-1300 0 0 0 0 0
1300-1400 0 0 0 0 0
1400-1500 0 0 0 0 0
1500-1600 0 0 0 0 0
1600-1700 0 0 0 0 0
1700-1800 0 0 0 0 0
1800-1900 0 0 0 0 0
1900-2000 2 2 0 0 0
2000-2100 0 0 0 0 0
2100-2200 0 0 0 0 0
2200-2300 0 0 0 0 0
2300-2400 0 0 0 0 0
Host/Domain Summary: Message Delivery
--------------------------------------
sent cnt bytes defers avg dly max dly host/domain
-------- ------- ------- ------- ------- -----------
2 1928 0 0.1 s 0.1 s zuo.com
Host/Domain Summary: Messages Received
---------------------------------------
msg cnt bytes host/domain
-------- ------- -----------
2 1928 zuo.com
Senders by message count
------------------------
2 aaa@qq.com
Recipients by message count
---------------------------
2 aaa@qq.com
Senders by message size
-----------------------
1928 aaa@qq.com
Recipients by message size
--------------------------
1928 aaa@qq.com
message deferral detail: none
message bounce detail (by relay): none
message reject detail: none
message reject warning detail: none
message hold detail: none
message discard detail: none
smtp delivery failures: none
Warnings
--------
smtpd (total: 3)
1 unknown[10.165.12.13]: SASL LOGIN authentication failed: UGFzc3...
1 hostname bogon does not resolve to address 10.165.12.13: Name o...
1 hostname bogon does not resolve to address 10.166.15.214: Name ...
Fatal Errors
------------
postfix-script (total: 1)
1 usage: postfix start (or stop, reload, abort, flush, check, sta...
Panics: none
Master daemon messages
----------------------
2 daemon started -- version 2.10.1, configuration /etc/postfix
1 terminating on signal 15
[aaa@qq.com ~]#
上一篇: N年以后,句句心痛,还有感动
下一篇: 汉语骂人最高境界