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

参考文献:

相关推荐
晨陌y6 分钟前
多台服务器怎么统一监控?哪吒面板部署、钉钉告警与远程访问教程
运维·服务器·钉钉
阿标在干嘛10 分钟前
政策快报平台日志系统的3次演进:从文件到ELK到告警
运维·elk·jenkins
味悲18 分钟前
Apache HTTP 服务器配置
服务器·http·apache
啦啦啦啦啦zzzz21 分钟前
oat++框架应用之do、dao、service
服务器·c++·mysql·oatpp
云计算磊哥@25 分钟前
运维开发宝典059-大型网站nginx服务器管理全集5
服务器·nginx·运维开发
黑白园28 分钟前
个人台式机VMware 15及Ubuntu 16.04.5卸载以及VMware 16.2.3及Ubuntu 24.04.4安装
linux·ubuntu
Inhand陈工35 分钟前
路由器专题二:有线为主,蜂窝备份——映翰通路由器链路备份功能详解
运维·网络·物联网·智能路由器·系统安全
腾科IT教育9 小时前
Oracle认证怎么选?2026年OCP/OCM报考指南
linux·运维·华为认证·hcie·开闭原则·datacom
幸福指北10 小时前
🚀 开源了,一个人 + AI 肝出一个 AI 终端 | AShell 技术分享
运维·人工智能·ai·终端
肥胖小羊11 小时前
微信社群自动化管理与防骚扰系统的设计与实现
运维·自动化