Leif160519的blog Leif160519的blog

——————

目录
Linux使用mutt发邮件
/  

Linux使用mutt发邮件

1.安装客户端

apt-get install msmtp mutt

2.配置msmtp

vim ~/.msmtprc
account         email_sender # 邮箱账户名称
host              mail.server.com #需要发送邮件的服务器
port              25 #邮件服务器端口号
from              email_sender@server.com #从哪个邮箱发出
auth              off #认证模式
user              sa_emailsender
password      123456 # 邮箱密码,有的是授权码
account default : emailsender # 默认邮箱账户
logfile           /var/log/msmtp.log # 邮件日志路径

修改完成后设置文件权限为600

chmod 0600 ~/.msmtprc

3.配置mutt

vim ~/.muttrc
set sendmail="/usr/bin/msmtp"
set use_from=yes
set realname="email_sender"
set from="email_server@server.com"
set envelope_from=yes
set editor="vim -nw"

4.发送邮件

echo "邮件内容" | mutt -s "邮件标题" -c aaa@server.com,bbb@server.com -a "附件" -- ccc@server.com,ddd@server.com

其中aaa和bbb为抄送邮件地址,ccc和ddd为发件箱地址,多个邮箱地址用逗号隔开

详细参数:

-a <文件> 在邮件中加上附加文件。
-b <地址> 指定密件副本的收信人地址。
-c <地址> 指定副本的收信人地址。
-f <邮件文件> 指定要载入的邮件文件。
-F <配置文件> 指定mutt程序的设置文件,而不读取预设的.muttrc文件。
-h 显示帮助。
-H <邮件草稿> 将指定的邮件草稿送出。
-i <文件> 将指定文件插入邮件内文中。
-m <类型> 指定预设的邮件信箱类型。
-n 不要去读取程序培植文件(/etc/Muttrc)。
-p 在mutt中编辑完邮件后,而不想将邮件立即送出,可将该邮件暂缓寄出。
-R 以只读的方式开启邮件文件。
-s <主题> 指定邮件的主题。
-v 显示mutt的版本信息以及当初编译此文件时所给予的参数。
-x 模拟mailx的编辑方式。
-z 与-f参数一并使用时,若邮件文件中没有邮件即不启动mutt。

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题Linux使用mutt发邮件
作  者Leif160519
出  处https://github.icu/articles/2021/06/02/1622615771782.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!