Linux下常用的MTA有sendmail、postfix、qmail、Exim。
Centos 6.4已经用postfix替代sendmail作为缺省的MTA了。
alternatives –-config mta
系统相关rpm包:
rpm -q postfix
postfix-2.6.6-2.2.el6_1.x86_64
rpm -q cyrus-sasl
cyrus-sasl-2.1.23-13.el6_3.1.x86_64
vi /etc/postfix/main.cf
myhostname = x.x.x
mydomain = x.x
myorigin = $mydomain
inet_interfaces =all
mynetworks = 192.168.11.0/24 #我的地址段
relay_domains = x.x, $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
重启postfix,service postfix,记得加入chkcofig 35 on。
接着chkconfig 35 saslauthd on。然后vi /etc/sysconfig/saslauthd
SOCKETDIR=/var/run/saslauthd
MECH=shadow
FLAGS=
vi /usr/lib64/sasl2/smtpd.conf
pwcheck_method: saslauthd
测试 saslauthd
service saslauthd restart
testsaslautd -u username -p 'password'
0: OK "Success."
在postfix 的配置文件中,添加以下内容,使其支持SMTP认证
vi /etc/postfix/main.cf
message_size_limit = 10737418 # 邮件的大小为10M
default_process_limit = 50
default_destination_concurrency_limit = 20
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_security_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
测试 25端口
telnet localhost 25
Trying 192.168.11.21...
Connected to localhost (192.168.11.21).
Escape character is '^]'.
220 x.x.x ESMTP Postfix
EHLO 163.com
250-x.x.x
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
现在可以测试一下给root发一封邮件,echo “this is a test mail!”|mail -s mail-subject x@gmail.com