安装配置和使用msmtp
sendmail是一个漏洞奇多、配置超级麻烦的东西,所以很多系统管理员都把它禁用了。
用 msmtp来代替它。 License(GPLv2), 从 msmtp-1.2.3 开始有windows版本
安装依赖包:
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh epel-release-6-8.noarch.rpm
# yum install libgsasl-devel
# yum install gnutls-devel libidn-devel
安装msmtp
http://sourceforge.net/projects/msmtp/files/msmtp/1.4.30/msmtp-1.4.30.tar.bz2/download
# tar -jxf /root/msmtp-1.4.30.tar.bz2
# ./configure
Install prefix ......... : /usr/local
TLS/SSL support ........ : yes (Library: GnuTLS)
GNU SASL support ....... : yes
GNU Libidn support ..... : yes
NLS support ............ : yes
GNOME Keyring support .. : no
MacOS X Keychain support : no
# make
# make install
# mkdir /var/msmtp
# touch /var/msmtp/msmtp.log
# vim /usr/local/etc/msmtprc
-------------------------------------------------------------------
defaults
account dengxxx
host smtp.yeah.net
port 25
from dengxxx@yeah.net
auth plain
user dengxxx@yeah.net
password xxx
account default : dengxxx
logfile /var/msmtp/msmtp.log
-------------------------------------------------------------------
配置文件说明,讲的非常详细。
/usr/local/share/info/msmtp.info
/usr/local/src/msmtp-1.4.30/doc/msmtp.info
-------------------------------------------------------------------
到了这里,简单测试一下
/usr/local/msmtp/bin/msmtp dxilong@163.com
随便输入一些内容用ctrl+d结束。
然后到邮箱看看有没有收到,如果这里提示错误按照错误代码找原因,
或者看看上面的日志文件
-----------------------------------------------------------------------------
3.让mail命令使用Msmtp而不是Sendmail
这个很简单,在/etc/mail.rc的末尾加一行:
set sendmail="/usr/local/bin/msmtp"
------------------------------------------------------------------------------
遇到的错误:
# msmtp dengxilong@go2matrix.net
msmtp: GNU SASL: Base 64 coding error in SASL library
msmtp: could not send mail (account default from /usr/local/etc/msmtprc)
遇到什么 Base64 编码错误的,只要将msmtprc 中的auth 项值由login 改为plain即可。
参考:
http://wiki.linux-ren.org/index.php/Msmtp
http://www.habadog.com/2011/11/23/send-mail-with-msmtp-mutt-linux/
http://storysky.blog.51cto.com/628458/293005
http://os.51cto.com/art/201209/358049.htm
http://www.crsay.com/wiki/wiki.php/server/centos/mutt-smtp-mail