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

参考文献:

相关推荐
IMPYLH34 分钟前
Linux 的 pinky 命令
linux·运维·服务器·bash
HelloWorld_SDK1 小时前
Docker安装OpenClaw
运维·docker·容器·openclaw
REDcker1 小时前
Linux iptables 与 Netfilter:原理、路径与运维要点
linux·运维·服务器
KKKlucifer3 小时前
零信任融合实践:国内堡垒机如何落地动态权限与实时阻断
运维
嵌入式×边缘AI:打怪升级日志3 小时前
Linux 驱动开发入门:从最简单的 hello 驱动到硬件交互
linux·驱动开发·交互
Bert.Cai4 小时前
Linux useradd命令详解
linux·运维
无忧.芙桃5 小时前
进程控制(上)
linux·运维·服务器
十年编程老舅5 小时前
深入 Linux 中断:原理详解 + 实战落地
linux·网络·linux内核·c/c++·中断
Bert.Cai5 小时前
Linux rm命令详解
linux·运维
航Hang*5 小时前
Windows Server 配置与管理——第8章:配置Web服务器
运维·服务器·windows·学习·vmware