下载msmtp包:
官方地址:http://msmtp.sourceforge.net/download.html
编译,安装(官方下载的包为tar.xz格式):
#xz -d msmtp-1.6.3.tar.xz #tar -xvf msmtp-1.6.3.tar #cd msmtp-1.6.3 #./configure --prefix /opt/apps/msmtp #make && make install
新建并配置msmtprc文件:
#mkdir /opt/apps/msmtp/etc #vi /opt/apps/msmtp/etc/msmtprc
# Set default values for all followingaccounts. defaults logfile /var/log/msmtp.log # The SMTP server of the provider. account service # SMTP邮件服务器地址 host smtp.163.com #端口 port 25 # 发送的邮件Email from mh_chen001@163.com auth login # 邮件服务器登录账号 user mh_chen001 # 邮件服务器登陆密码 Password password ------------注意这里应该配置163邮箱的客户端授权验证码 # Set a default account account default : service
测试msmtp是否能够发送邮件:
#/opt/apps/msmtp/bin/msmtp user@yourmail.com
如果能收到邮件,msmtp则正常工作。
安装:
#yum -y installsharutils.x86_64
配置mutt,修改如下配置:
#vi/etc/Muttrc setsendmail="/opt/apps/msmtp/bin/msmtp" set use_envelope_from=yes set from=mh_chen001@163.com setrealname="mh_chen001" set use_from=yes
测试mutt邮件发送:(带附件)
#echo ‘Hello!This is the statics of the Method and Method_costTime today,please check!‘ |mutt -s "Method and costTime statics" -a Method_Statistics_2015.12.22.tar.gz-- user@yourmail.com
查看邮件日志:
#tail -f /var/log/msmtp.log Dec 1506:50:54 host=smtp.163.com tls=off auth=on user=mh_chen001from=mh_chen001@163.com recipients=359275330@qq.com mailsize=4958 smtpstatus=250smtpmsg=‘250 Mail OK queued as smtp7,C8CowEA50Fdm8nhWWf0SAA--.3655S21450766951‘ exitcode=EX_OK
从日志中可看到发送状态250,邮件发送成功,登录客户端查看邮件:
邮件发送正常,附件正常。
本文出自 “扮演上帝的小丑” 博客,请务必保留此出处http://icenycmh.blog.51cto.com/4077647/1727213
原文地址:http://icenycmh.blog.51cto.com/4077647/1727213