配置SELinux
查看是否安装SELinux
[root@ebs-51660 ~]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing -SELinux security policy is enforced.
# permissive -SELinux prints warnings instead of enforcing.
# disabled -No SELinux policy is loaded.SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible valuesare:
# targeted- Only targeted network daemons are protected.
# strict -Full SELinux protection.SELINUXTYPE=targeted
安装SELinux
[root@ebs-51660 ~]# yum install selinux-policy-targeted
wget linuxmail.info/files/rhel6/postfixdovecotsasl.te html
checkmodule -M -m -o postfixdovecotsasl.mod postfixdovecotsasl.te linux
semodule_package -o postfixdovecotsasl.pp -m postfixdovecotsasl.mod vim
semodule -i postfixdovecotsasl.ppcentos
安装 cyrus-sasl 软件包
[root@ebs-51660 ~]# yum install cyrus-sasl*服务器
(A)使用/etc/shadow文件验证dom
[root@ebs-51660 ~]# vi /etc/sysconfig/saslauthdsocket
MECH=shadowtcp
FLAGS=post
[root@ebs-51660 ~]# vi /etc/sasl2/smtpd.conf 测试
pwcheck_method: saslauthd
mech_list: plain login
(B)使用/etc/sasldb文件验证
[root@ebs-51660 ~]# vi /etc/sysconfig/saslauthd
#MECH=pam #注释掉原文此行
FLAGS=sasldb
[root@ebs-51660 ~]# vi /etc/sasl2/smtpd.conf
pwcheck_method: auxprop
auxprop_plugin: sasldb
mech_list: plain login
[root@ebs-51660 ~]# saslpasswd2 -c admin -u kingmed.com
按提示输入两次密码(不要与系统密码相同),首次操做会生成/etc/sasldb2文件。
[root@ebs-51660 ~]# chgrp postfix /etc/sasldb2
[root@ebs-51660 ~]# chmod 640 /etc/sasldb2
启动saslauthd
[root@ebs-51660 ~]#chkconfig saslauthd on
[root@ebs-51660 ~]#service saslauthd start
[root@ebs-51660 ~]# /usr/sbin/testsaslauthd -u admin -p '123456' #用系统密码测试
0: NO "authentication failed"
解决办法:
[root@ebs-51660 ~]# setsebool -P allow_saslauthd_read_shadow 1
若是仍是不能成功,则看的main.cf文件配置是否有错
开放相关端口
[root@ebs-51660 ~]# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m multiport --dports 25,80,110,143 -j ACCEPT
[root@ebs-51660 ~]# service iptables restart
重启postfix
[root@ebs-51660 ~]# chkconfig postfix on
[root@ebs-51660 ~]# service postfix restart
检验配置是否正确
postfix 提供了check命令,能够检查当前postfix 的配置是否有问题、文件和目录权限是否正确
发送邮件测试
echo 'test' | mail -s 'test' test@test.com
Telnet登陆验证
新安装的centos系统是没有安装telnet的,须要本身安装Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.kingmed.com ESMTP Postfix
ehlo localhost
250-mail.kingmed.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH DIGEST-MD5 GSSAPI PLAIN CRAM-MD5 LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth login
334 VXNlcm5hbWU6
bGl1eXVodWlAa2luZ21lZC5jb20= #liuyuhui@kingmed.com的BASE64编码
334 UGFzc3dvcmQ6
bGl1eXVodWk= #密码liuyuhui的BASE64编码
235 2.7.0 Authentication successful
mail from:liuyuhui@kingmed.com
250 2.1.0 Ok
rcpt to:jiangtao@kingmed.com
250 2.1.5 Ok
data
354 End data with . #回车后以点号(.)结束
hello,how are you?
250 2.0.0 Ok: queued as 934C83622
quit
221 2.0.0 Bye
Connection closed by foreign host.
来看下jiangtao用户家目录下是否有此邮件(注意queued as 934C83622):
[root@mail ~]# cat /home/jiangtao/Maildir/new/1375283408.Vfd00I3696M538506.mail.kingmed.com
Return-Path:
X-Original-To: jiangtao@kingmed.com
Delivered-To: jiangtao@kingmed.com
Received: from localhost (localhost [127.0.0.1])
(Authenticated sender: liuyuhui@kingmed.com)
by mail.kingmed.com (Postfix) with ESMTPA id 934C83622
for ; Wed, 31 Jul 2013 23:09:20 +0800 (CST)
Message-Id: <20130731150940.934C83622@mail.kingmed.com>
Date: Wed, 31 Jul 2013 23:09:20 +0800 (CST)
From: liuyuhui@kingmed.com
To: undisclosed-recipients:;
hello,how are you?
POP/ IMAP设置
为了让用户能在本地机器下载邮件,必须在服务器安装设置POP或IMAP。Dovecot是适用CentOS Linux邮件系统有名的imap/pop服务器之一,它支持maildir和mbox格式。
安装dovecot
[root@ebs-51660 ~]# yum -y install dovecot
[root@ebs-51660 ~]# vim /etc/dovecot/dovecot.conf
protocols = imap pop3 // 大概在20行的位置
listen = * // 27行左右
[root@ebs-51660 ~]# vim /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no // 9行,将yes改成no并去掉#号
auth_mechanisms = plain login // 97行
[root@ebs-51660 ~]# vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir
[root@ebs-51660 ~]# vim /etc/dovecot/conf.d/10-master.conf
service auth {
unix_listener auth-userdb {
}
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
}
[root@ebs-51660 ~]# vim /etc/dovecot/conf.d/10-ssl.conf
ssl = no
[root@ebs-51660 ~]# vim /etc/dovecot/conf.d/20-pop3.conf
pop3_uidl_format = XuXv
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
配置完后使用dovecot -n查看全部配置。
启动dovecot:
[root@ebs-51660 ~]# chkconfig dovecot on
[root@ebs-51660 ~]# service dovecot start
如今你可使用邮件客户端代理软件和系统用户及密码来链接咱们的Dovecot服务器了。
未完待续 http://www.cnblogs.com/apexchu/p/4271264.html http://blog.chinaunix.net/uid-20362960-id-1699884.html http://my.oschina.net/u/2450048/blog/531171 http://www.mamicode.com/info-detail-1162987.html http://blog.jjonline.cn/linux/185.html