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

参考文献:

相关推荐
tap.AI5 分钟前
Deepseek(九)多语言客服自动化:跨境电商中的多币种、多语种投诉实时处理
运维·人工智能·自动化
ling-4512 分钟前
Linux-day09 11
linux·运维·服务器
202321336054 刘12 分钟前
Linux常用命令分类整理
linux·运维·数据库
南工孙冬梅14 分钟前
【久久派】 新世界系统安装
linux
zbguolei14 分钟前
Debian提示:“用户名” 不是 sudoers 文件
linux·服务器·debian
oMcLin15 分钟前
如何在 Debian 11 上通过配置 LVM 和 RAID 结合,提升大规模存储系统的性能与冗余性
运维·debian
梦星辰.15 分钟前
超大 JSONL 数据集交互式查看器 Linux便捷工具
linux·windows·microsoft
C_心欲无痕24 分钟前
网络相关 - Ngrok内网穿透使用
运维·前端·网络
宇钶宇夕27 分钟前
CoDeSys入门实战一起学习(四):应用程序运行、监控与调试
运维·自动化
optimistic_chen27 分钟前
【Redis系列】主从复制
linux·数据库·redis·缓存·中间件·命令行·主从复制