使用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

参考文献:

相关推荐
奋斗的蛋黄1 小时前
硬链接(Hard Link)与软连接(Symbolic Link)核心解析
linux
先做个垃圾出来………1 小时前
DeepDiff差异语义化特性
服务器·前端
i建模1 小时前
Omarchy挂载windows磁盘
linux·运维·windows
林姜泽樾2 小时前
linux基础第一章,linux的介绍和它和windows的区别
linux·运维·计算机网络·安全·网络安全
nudt_qxx2 小时前
Ubuntu 26.04 LTS“坚毅浣熊”(Resolute Raccoon) 新特性前瞻
linux·数据库·ubuntu
白云偷星子2 小时前
RHCSA笔记6
linux·笔记
2401_849339172 小时前
LVS实验
服务器·网络·lvs
i建模2 小时前
在 **Omarchy**(基于 Arch Linux 的发行版)中检查当前内核是否支持 NTFS 文件系统
linux·运维·服务器
bwz999@88.com2 小时前
CentOS 7安装ollama
linux·centos·ollama
Emotional。2 小时前
AI Agent 开发实战:用 LangChain 构建智能邮件助手
linux·服务器·网络·人工智能·python·langchain