1.rpm方式安装好apache+php测试PHP正常访问。(为webmail先搭建好运行环境)
2.yum安装postfix(安装postfix前先卸载sendmail)和dovecot(pop3+imap),启动两个服务。
3.配置dovecot: vi /etc/dovecot.conf,dovecot 只需把protocols前的注释去掉,修改protocols = imap imaps pop3 pop3s,并重起 service dovecot restart
4.修改postfix配置文件/etc/postfix/main.cf
#myhostname = host.domain.tld  ← 找到此行,将等号后面的部分改写为主机名
myhostname = sample.centospub.com  ← 变为此状态,设置系统的主机名

#mydomain = domain.tld  ← 找到此行,将等号后面的部分改写为域名
mydomain = centospub.com  ← 变为此状态,设置域名(我们将让此处设置将成为E-mail地址“@”后面的部分)

#myorigin = $mydomain  ← 找到此行,将行首的#去掉
myorigin = $mydomain  ← 变为此状态,将发信地址“@”后面的部分设置为域名(非系统主机名)

inet_interfaces = localhost  ← 找到此行,将“localhost”改为“all”
inet_interfaces = all  ← 变为此状态,接受来自所有网络的请求

mydestination = $myhostname, localhost.$mydomain, localhost  ← 找到此行,在行为添加“$mydomain”
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain  ← 变为此状态,指定发给本地邮件的域名

#relay_domains = $mydestination  ← 找到此行,将行首的#去掉
relay_domains = $mydestination  ← 变为此状态,定义允许转发的域名

#mynetworks = 168.100.189.0/28, 127.0.0.0/8  ← 找到此行,依照自己的内网情况修改
mynetworks = 168.100.189.0/28, 127.0.0.0/8  ← 变为此状态,指定内网和本地的IP地址范围

#home_mailbox = Maildir/  ← 找到这一行,去掉行首的#
home_mailbox = Maildir/  ← 变为此状态,指定用户邮箱目录 (这个一般不用做)

# SHOW SOFTWARE VERSION OR NOT
#
# The smtpd_banner parameter specifies the text that follows the 220
# code in the SMTP server's greeting banner. Some people like to see
# the mail version advertised. By default, Postfix shows no version.
#
# You MUST specify $myhostname at the start of the text. That is an
# RFC requirement. Postfix itself does not care.
#
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)  ← 找到这一行,接此行添加如下行:
smtpd_banner = $myhostname ESMTP unknow  ← 添加这一行,不显示SMTP服务器的相关信息

在配置文件的文尾,添加如下行:

smtpd_sasl_auth_enable = yes  ← 服务器使用SMTP认证
smtpd_sasl_local_domain = $myhostname  ← 指定SMTP认证的本地域名(主机名)
smtpd_sasl_security_options = noanonymous   ← 不允许匿名的方式认证
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
message_size_limit = 15728640  ← 规定邮件最大尺寸为15MB

vi /usr/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd
log_level:3
mech_list:PLAIN LOGIN

如此,postfix应该可以使用本地系统用户收发邮件了。

=================================================================================