[Linux] mutt+msmtp sendmail

tolilong發表於2016-03-04
以前也寫過mutt+msmtp sendmail的文章,現在重新寫一次吧。

1.download msmtp software
直接輸入如下地址,可以獲得software


2.install msmtp
[root@oracle6 opt]# tar -xvf msmtp-1.4.31.tar.bz2 
[root@oracle6 opt]# cd msmtp-1.4.31
[root@oracle6 msmtp-1.4.31]# ./configure --prefix=/opt/msmtp --with-ssl=openssl
[root@oracle6 msmtp-1.4.31]# make
[root@oracle6 msmtp-1.4.31]# make install

3.配置配置檔案
[root@oracle6 etc]# pwd
/opt/msmtp/etc
[root@oracle6 etc]# more msmtprc 
account default
host smtp.163.com
port 25
from tolilong@163.com
auth login
tls off
user tolilong@163.com
password xxxxxx
logfile /var/log/mmlog


[root@oracle6 ~]# more /etc/Muttrc 
set from="tolilong@163.com"
set sendmail="/opt/msmtp/bin/msmtp"
set use_from=yes
set realname="SystemInfo"
set editor="vi"




4.sendmail
[root@oracle6 ~]# echo "Log" | mutt -s "Log Info" -a /root/install.log.syslog tolilong@163.com
[root@oracle6 ~]# cat install.log.syslog | mutt -s "Log Info" -a /root/install.log.syslog tolilong@163.com
[root@oracle6 ~]# cat install.log.syslog | mutt -s "Log Info" -a /root/install.log.syslog tolilong@163.com,bruce_xxxx@163.com


-s=subject(主題)
-a=attachment(附件)
多個maillist中間用逗號","分開

*******************************************************************
[root@oracle6 ~]# cat install.log.syslog | mutt -s "Log Info" -a test tolilong@163.com
Can't stat tolilong@163.com: No such file or directory
tolilong@163.com: unable to attach file.

遇到如上一個問題,即傳送帶附件的mail的時候報瞭如上這個錯誤。
將mail list放到 -a 引數即可以

[root@oracle6 ~]# cat install.log.syslog | mutt -s "Log Info" tolilong@163.com  -a test
[root@oracle6 ~]# cat install.log.syslog | mutt -s "Log Info" tolilong@163.com,bruce_xxxxx@163.com  -a /root/install.log.syslog 
*******************************************************************


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-2040198/,如需轉載,請註明出處,否則將追究法律責任。

相關文章