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

参考文献:

相关推荐
代码不停40 分钟前
Linux基础知识
java·linux·数据库
木雷坞1 小时前
Docker 镜像源列表(11月30日更新-长期)
运维·docker·容器
feasibility.1 小时前
电脑一天重启3次、WiFi还消失:蓝屏0x9F背后,是MT7921网卡撞上Windows电源管理
服务器·网络·windows·wifi·电脑·网卡·驱动
顧棟1 小时前
INFINI Gateway 启动过程分析
服务器·网络·gateway
东风微鸣1 小时前
Linux台式机也能指纹识别登录验证啦
linux·指纹
迪康软件zz3 小时前
单向阀的代码:把"高级别解低级别"写成可测的判定
运维·安全·自动化运维
xbzb3 小时前
服务器与网络:从一台裸机到能联网跑服务(5 篇)
服务器·网络·ip·raid·blog.csdn.net·article
Diligently_3 小时前
docker 中的常见的使用命令(三)
运维·docker·容器
路溪非溪3 小时前
USB的基础知识总结
linux
女神下凡3 小时前
芯易选(143):晶视智能(CVITEK)_开发指南
linux·arm开发·stm32·单片机·嵌入式硬件