1、Mutt安裝及環境配置
1.1、安裝
sudo yum install mutt
比如你要設置郵件的發信人,需要做:
sudo vim /etc/Muttrc set envelope_from=yes set from=yourname@xxx.com set realname="yourname" set use_from=yes
1.2、測試是否安裝
測試發送郵件,基本文本。如果多個收信人之間用,隔開
echo "測試mutt" | mutt -s "測試mutt" xxx@xxx.com
發送附件,如果要發送多個附件,需要用多個-a
echo "測試mutt" | mutt -s "測試mutt" xxx@xxx.com -a /tmp/test.txt
將文本文件內容作為正文
mutt -s "測試mutt" xxx@xxx.com < /tmp/test.txt
如果想郵件內容有 樣式,可以搞htm文檔作為郵件正文
mutt -s "測試mutt" -e 'set content_type="text/html"' xxx@xxx.com < /tmp/test.html
test.html可以簡單的為:
<html> <head></head> <body> <table> <tbody> <tr> <td>1</td> <td>test1</td> <td>2</td> <td>test2</td> </tr> <tr> <td>3</td> <td>test3</td> <td>4</td> <td>test4</td> </tr> </tbody> </table> </body> </html>
2、安裝出錯及其處理方法:
2.1、send-mail: fatal: parameter inet_interfaces: no local interface found for ::1
發送郵件:
[root@iZ23whn33jnZ log]# echo '這是郵件標題' | mail -s "這是郵件內容" 9379963xx@qq.com
出現異常:
[root@iZ23whn33jnZ log]# send-mail: fatal: parameter inet_interfaces: no local interface found for ::1
查看centos中的postfix日志
more /var/log/maillog
postfix: fatal: parameter inet_interfaces: no local interface found for ::1
vi /etc/postfix/main.cf
發現配置為:
inet_interfaces = localhost
inet_protocols = all
改成:
inet_interfaces = all
inet_protocols = all
重新啟動
service postfix start
OK!
參考:
2、send-mail: fatal: parameter inet_interfaces: no local interface found for ::1