使用linux的mail命令发送html格式的邮件

1、关闭本机的sendmail服务或者postfix服务

bash 复制代码
#执行下面的命令,各位大侠都对号入座吧
#sendmial
service sendmail stop
chkconfig sendmail off
#postfix
service postfix stop
chkconfig postfix off

#再狠一点就直接卸载吧..
yum remove sendmail
yum remove postfix

2、然后修改/etc/mail.rc,在文件末尾增加以下内容,指定邮箱和授权码

bash 复制代码
set from=123456@qq.com
set smtp=smtp.qq.com  
set smtp-auth-user=123456
set smtp-auth-password=你的授权码
set smtp-auth=login  

3、授权码的获取方式

4、然后通过命令来发送邮件

bash 复制代码
echo  hello word | mail -s " title" 123456@qq.com  

如果希望带html格式的内容,可以这么发:

bash 复制代码
echo "<b><div style='color:red'>HTML Message goes here</div></b>" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")"  123456@qq.com

参考文献:

相关推荐
Ai拆代码的曹操13 分钟前
K8s Pod Pending 逐层排查:从 FailedScheduling 到 PVC StorageClass 不存在的实战记录
java·linux·kubernetes
Yang96111 小时前
探索无线新视界:鼎讯信通DXMP系列频谱仪模块深度剖析
运维·网络
wangbing11251 小时前
JPA下自定义主键
java·linux·服务器
杨了个杨89821 小时前
Docker Compose 简介及应用
运维·docker·容器
bush41 小时前
正点原子imx6ull-uboot,奇怪的问题
linux·学习
Urbano2 小时前
卫衣生产工艺科普与智能自动化设备应用解析
大数据·运维·人工智能
dddwjzx2 小时前
嵌入式Linux C应用编程——Framebuffer应用编程
linux·嵌入式
lastHertz3 小时前
Nginx安装部署
运维·nginx
今天也想躺ping3 小时前
linux系统移植pjsua库实现sip通话功能
linux·sip·交叉编译