1,安裝mutt
sudo apt-get install mutt
2,安裝msmtp
sudo apt-get install msmtp
3,設置mutt
/etc/Muttrc # 系統全局設置
~/.muttrc # 使用某個系統用戶
raspberrypi# vim ~/.muttrc
set sendmail="/usr/bin/msmtp"
set use_from=yes
set realname="name_post" # 發件人昵稱
set editor="vi"
set from=xxx@xxxx.com # 發件人郵箱
set envelope_from=yes
set crypt_use_gpgme=no
#tls off
4,設置msmtp
創建 ~/.msmtprc 和 ~/.msmtp.log 分別為配置和日志文件
raspberrypi# vim ~/.msmtprc
account default
host smtp.xxxx.com # 可在郵箱設置中查看
user xxxx # 一定要是郵箱@前的部分
from xxxx@xxxx.com
password 123456 # 郵箱密碼(有可能為授權碼)
auth plain
logfile ~/.msmtp.log
5,查看SMTP服務器是否支持認證的TLS加密
raspberrypi# msmtp --host=smtp.sina.com --serverinfo
SMTP server at smtp.sina.com (xk-6-242-a8.bta.net.cn [202.108.6.242]), port 25:
smtp-5-121.smtpsmail.fmail.xd.sinanode.com ESMTP
Capabilities:
STARTTLS:
Support for TLS encryption via the STARTTLS command
AUTH:
Supported authentication methods:
PLAIN LOGIN
This server might advertise more or other capabilities when TLS is active.
可見支持認證(若不支持取消注釋.muttrc中的最后一項,未親測,一般都支持)。
6,測試發郵件
echo 正文 | mutt -s 主題 xxxx@xx.com -a 附件
總結
以上所述是小編給大家介紹的樹莓派 msmtp和mutt 的安裝和配置教程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!