2014-09-27 18:14:30
来 源
中存储网
MySQL
CentOS 5系统中如何配置sendmail imap,pop3,smtp认证的步骤方法:本文介绍CentOS5 配置sendmail 支持imap,pop3,smtp软件收发,测试正常可行的,分享如下。

CentOS 5系统中如何配置sendmail imap,pop3,smtp认证的步骤方法:

本文介绍CentOS5 配置sendmail 支持imap,pop3,smtp软件收发,测试正常可行的,分享如下。

CentOS5 配置sendmail imap,pop3,smtp认证
查看安装
rpm -qa | grep sendmail
rpm -qa | grep dovecot
rpm -qa | grep cyrus
安装邮件服务器
yum install sendmail sendmail-cf
安装pop3/imap服务
yum install dovecot

安装用户认证
yum install cyrus-sasl
yum install cyrus-sasl-md5
yum install cyrus-sasl-plain
yum install cyrus-sasl-lib

修改sendmail配置
vi /etc/mail/sendmail.mc

第42行和43行,把最前面的dnl删除,变成:
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS',`EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

修改SMTP的监听IP为 0.0.0.0
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl

生成配置
m4 /etc/mail/sendmail.mc > /etc/sendmail.cf
***************************
如果出现:sendmail.mc:10: m4: cannot open `/usr/share/sendmail-cf/m4/cf.m4': No such file or directory
说明需要安装sendmail-cf
yum install sendmail-cf
***************************

修改dovecot配置
vi /etc/dovecot.conf
去掉下面一行前面的#
#protocols =imap imaps pop3 pop3s

添加域名
vi /etc/mail/local-host-names
添加域名如:dirtysea.com //每个域名一行

修改认证方式
vi /usr/lib/sasl2/Sendmail.conf 里面指明了:pwcheck_method=saslauthd,不做修改
vi /etc/sysconfig/saslauthd 找到第7行的:MECH=pam 改成:MECH=shadow
保存

如下示列:
[root@mail]# cat /usr/lib/sasl2/Sendmail.conf
pwcheck_method:saslauthd
[root@mail]# cat /usr/lib/sasl2/smtpd.conf.rpmsave
log_level: 3
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
[root@mail]# cat /etc/sysconfig/saslauthd
# Directory in which to place saslauthd's listening socket, pid file, and so
# on. This directory must already exist.
SOCKETDIR=/var/run/saslauthd
# Mechanism to use when checking passwords. Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=shadow
# Additional flags to pass to saslauthd on the command line. See saslauthd(8)
# for the list of accepted flags.
FLAGS=
[root@mail]#testsaslauthd -u test -p 123456 (验证smtp)

0: OK "Success."

添加邮件用户
[root@localhost named]# groupadd mailuser
[root@localhost named]# adduser -g mailuser -s /sbin/nologin kf

sasldblistusers2 检查已经增加的smtp验证用户(必须用这个添加到验证里,否则无法收发邮件)
saslpasswd2增加smtp验证用户:saslpasswd2 -u t3t3.org -c kf

smtp验证测试: testsaslauthd -u kf -p 123456

重启
service sendmail restart
service dovecot restart
service saslauthd restart

设置开机启动
chkconfig sendmail on
chkconfig dovecot on
chkconfig saslauthd on

验证Sendmail服务
telnet localhost 25 //输入helo localhost 此时应该有LOGIN PLAIN的字样,即表示SMTP认证设置成功。

[root@centos5 mail]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 centos5 ESMTP Sendmail 8.13.8/8.13.8; Thu, 6 May 2010 06:21:29 +0800
helo localhost
250 centos5 Hello localhost.localdomain [127.0.0.1], pleased to meet you
mail from:
250 2.1.0 ... Sender ok
rcpt to: (要测试向外发送邮件就填写网络上存在的邮件地址)
250 2.1.5 ... Recipient ok
data
354 Enter mail, end with "." on a line by itself
From: alin
To: alin
Subject: Hello
test
.
250 2.0.0 o45MLTcH005157 Message accepted for delivery
quit
221 2.0.0 centos5 closing connection
Connection closed by foreign host.

***************************************
root@yes81 ~]# telnet localhost 110
Trying 127.0.0.1...
Connected to yes81.localdomain (127.0.0.1).
Escape character is '^]'.
+OK Dovecot ready.
user web
+OK
pass 123456
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.

ok,可以使用outlook或foxmail进行测试收发了。

注意:为什么没有设定foxmail中的smtp服务器需要验证,也可以发送E-mail?
要用OUTLOOK来测试,Foxmail似乎可以自动地进行smtp认证。OUTLOOK在smtp服务器验证失败后,有拒绝提示

工具->;帐户->;邮件->;属性->;服务器->;我的服务器要求身份验证(选上)->;设置->;(选择)登录方式->;帐户名:(用saslpasswd2建

立的),密码(用saslpasswd2建立的)->;确定.
另外:接收邮件服务器的帐户名与密码应该是系统里的用户名与密码.

saslauthd -v 看结果支不支持 pam或shadow
smtp验证测试: testsaslauthd -u test -p 123456
sasldblistusers2 检查已经增加的smtp验证用户
saslpasswd2增加smtp验证用户:saslpasswd2 -u cencn.com -c test

查看sendmail队列:mailq
立即发送队列里的邮件: sendmail –oQ/var/spool/mqueue.stop -q
察看邮件系统的状态:mailstats
查看暂时存储邮件:ls -l /var/spool/mail |more

-------------------------------------------------------------------------
比如帐号是web 密码是123445  邮件域名为yes81.net
--->发送和接收服务器为yes81.net 则只要在帐号那里输入web密码那里输入123445

刚开始安装只能发不能收,就是pop3不支持,花了我2天时间,原来在发邮件时候可以使用帐号web@yes81.net 但接收时候只能使用web的。现在是统一使用web作为帐号就解决了。
------------------------------------------------------

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。