yum install mail

由于Linux 5级以下的版本默认使用sendmail发送mail,关闭sendmail之后将无法发送mail,而Linux 6却可以,他们主要区别是使用mailx的版本不一样.Linux6使用mailx 版本mailx-12.4-6.el6.x86_64Linux 5使用mailx版本mailx-8.1.1-44.2.2

故为了让linux 5在关闭sendmail的情况下,使用外部SMTP发送mail,需要在Linux5上安装mailx-12.4-6.el6.x86_64.



.#####卸载旧版mailx

可以先卸载旧版本mail 一般centos5.8mailx8.1

[root@10-10-86-221mailx-12.4]# rpm -qa|grep mailx

mailx-8.1.1-44.2.2

[root@10-10-86-221mailx-12.4]#

[root@10-10-86-221mailx-12.4]# rpm -e mailx-8.1.1-44.2.2 --nodeps

warning:/etc/mail.rc saved as /etc/mail.rc.rpmsave

.########安装

# mkdir/opt/mailx

# cd/opt/mailx/

# wget http://ncu.dl.sourceforge.net/project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2

# tar-jxvf mailx-12.4.tar.bz2

#make

[root@10-10-86-221mailx-12.4]# make install UCBINSTALL=/usr/bin/install


修改 /etc/mail.rc  如果是手动安装mailx的话,配置文件为/etc/nail.rc

清空文件加入

set from=ysy399268824@163.com smtp=smtp.163.com  #smtpserver
set smtp-auth-user=ysy399268824 smtp-auth-password=密码 smtp-auth=login #smtp account


因为mail命令默认会使用sendmail或者postfix发送邮件

sendmail
# service sendmail stop
# chkconfig sendmail off

postfix
# service postfix stop
# chkconfig postfix off

然后测试

echo helloword|mail -s "test" xxxxxx@qq.com


测试smtp登录可以使用windows测试下 参考他的微博 http://blog.sina.com.cn/s/blog_6dbfc2a901014yqx.html

telnet smtp.163.com

helo 163.com

auth login