安裝mutt和msmtp
# yum install mutt
# yum install msmtp
配置mutt
- root用戶添加root/.muttrc配置文件
- 普通用戶添加~/.muttrc配置文件
set use_from=yes
set envelope_from=yes
set charset="utf-8"
auto_view text/html #自動顯示HTML
# 發送者賬號
set realname="Tom"
set from="[email protected]"
# 關聯程序
# 郵件使用vim作爲編輯器
set editor="vim -nw"
# msmtp路徑可以用which msmtp查看
set sendmail="/usr/bin/msmtp"
配置msmtp
- root用戶添加root/.msmtprc配置文件
- 普通用戶添加~/.msmtprc配置文件
account default
auth login
# 需要查看郵箱服務器的POP或smtp設置
host smtp.163.com
port 12345
from [email protected]
user tom # 郵箱賬號
password 123456 # 郵箱密碼
tls on
tls_certcheck off
logfile /tmp/msmtp.log
至此,發送郵件的配置已完成
測試
測試1:使用默認配置發送郵件
測試時,郵件的發送方就是~/.muttrc
中設置的from
,即[email protected]
這裏注意,from
需要與~/.msmtprc
中設置的from
相同
echo "from: tom.163.com" | mutt -s "測試郵件默認配置"[email protected]
參考
- https://blog.csdn.net/weixin_34279579/article/details/88581554