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

参考文献:

相关推荐
ITOWARE_SAPer23 分钟前
选择SAP实施公司能否兼得官方授权与高性价比?
运维·能源·制造·零售
开压路机24 分钟前
进程控制
linux·服务器
香蕉鼠片25 分钟前
跨平台开发到底是什么
linux·windows·macos
Elastic 中国社区官方博客39 分钟前
Elasticsearch:快速近似 ES|QL - 第一部分
大数据·运维·数据库·elasticsearch·搜索引擎·全文检索
2401_873479401 小时前
如何从零搭建私有化IP查询平台?数据采集、清洗、建库到API发布全流程
服务器·网络·tcp/ip
AC赳赳老秦2 小时前
OpenClaw生成博客封面图+标题,适配CSDN视觉搜索,提升点击量
运维·人工智能·python·自动化·php·deepseek·openclaw
Eric.Lee20212 小时前
docker 启动停止命令
运维·docker·容器
samson_www3 小时前
EC2的GRUB引导程序问题
运维·ai
bukeyiwanshui3 小时前
20260417 DNS实验
linux
代码中介商3 小时前
Linux 帮助手册与用户管理完全指南
linux·运维·服务器