使用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 小时前
网络协议计时器 & 发包间隔汇总
运维·网络·tcp/ip
Wang's Blog6 小时前
Java 接入Redis: 服务启动停止与后台运行配置
java·服务器·redis
云运维笔记7 小时前
IP地址从入门到精通:网络通信的核心基石
运维·网络·计算机网络
bosins8 小时前
WSL2 启动即崩溃?调整超时参数解决 Docker 阻塞问题
linux·docker·wsl
web守墓人8 小时前
【goed/ui】自定义组件设计思想篇
linux·windows·ui·golang
码农学院9 小时前
企业官网改版后 AI 引用归零的复盘:301 重定向断层让爬虫索引掉线,修复方案与恢复数据
运维·geo优化·ai优化aio
kuroomi9 小时前
Ingress-Nginx与kubernetes 网络
linux·运维·网络·kubernetes
当下新鲜事9 小时前
空调机房冷冻泵与冷却泵技术分析:赛莱默B&G背包式智能变频管道泵的工程应用
运维·物联网·业界资讯
EasyGBS9 小时前
终结训推割裂!EasyGBS×EasyAIS×DLTM,实现AI算法训推一体闭环落地!
服务器·深度学习·安全
daemon.qiang9 小时前
国内虚拟机对接 Freedesktop:Fork xserver、自建 Runner 与提交 MR 实战
linux·ubuntu·centos·gitlab·开源软件