CentOS:mutt+msmtp發送郵件

安裝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]

參考

  1. https://blog.csdn.net/weixin_34279579/article/details/88581554
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章