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

参考文献:

相关推荐
心易行者5 小时前
Agent应用+API端点商业化进阶实战:从单体智能体到可付费调用的API全流程
运维·服务器·人工智能·python·apache
科技研学社5 小时前
精度决胜品质:羽绒服缝制工艺标准与自动化精度对标解析
运维·自动化
夜之眷属5 小时前
Core dump 崩溃排查:JVM 宕机后,那份 core 文件怎么用 gdb 还原现场
java·运维·服务器·jvm
Initialize293085 小时前
Redis 内存打满、连接数飙红?运维排查四步法
运维
zly35005 小时前
centos7 mount设备挂载 /dev/sda1/硬盘挂载
linux·运维·服务器
零基础1235 小时前
FinalShell 使用教程:从安装到高效运维
运维·经验分享·笔记·finalshell
帷幕落秋5 小时前
Docker的两种安装
运维·docker·容器
工业一体机老司机5 小时前
工业一体机选购后的系统部署:Ubuntu下Docker容器化运行与GPIO配置
linux·ubuntu·docker·人机交互
fengkai45456 小时前
十二、Redis -2
运维·数据库·redis·容器