標籤:msmtp mutt
1:搭建配置msmtp
下載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.defaultslogfile /var/log/msmtp.log# The SMTP server of the provider.account service# SMTP郵件伺服器地址host smtp.163.com#連接埠port 25# 發送的郵件Emailfrom [email protected]auth login# 郵件伺服器登入帳號user mh_chen001# 郵件伺服器登陸密碼Password password ------------注意這裡應該配置163郵箱的用戶端授權驗證碼# Set a default accountaccount default : service
測試msmtp是否能夠發送郵件:
#/opt/apps/msmtp/bin/msmtp [email protected]
如果能收到郵件,msmtp則正常工作。
2:安裝配置mutt
安裝:
#yum -y installsharutils.x86_64
配置mutt,修改如下配置:
#vi/etc/Muttrcsetsendmail="/opt/apps/msmtp/bin/msmtp"set use_envelope_from=yesset [email protected]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-- [email protected]
查看郵件日誌:
#tail -f /var/log/msmtp.logDec 1506:50:54 host=smtp.163.com tls=off auth=on [email protected] [email protected] mailsize=4958 smtpstatus=250smtpmsg=‘250 Mail OK queued as smtp7,C8CowEA50Fdm8nhWWf0SAA--.3655S21450766951‘ exitcode=EX_OK
從日誌中可看到發送狀態250,郵件發送成功,登入用戶端查看郵件:
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/78/42/wKioL1Z5AjnjhhNyAAB7hurKpvw939.png" title="1.png" alt="wKioL1Z5AjnjhhNyAAB7hurKpvw939.png" />
郵件發送正常,附件正常。
本文出自 “扮演上帝的小丑” 部落格,請務必保留此出處http://icenycmh.blog.51cto.com/4077647/1727213
CentOS搭建msmtp+mutt實現郵件發送