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

参考文献:

相关推荐
小义_17 分钟前
随笔 3(Linux)
linux·运维·服务器·云原生·红帽
#六脉神剑37 分钟前
MySQL参数调优:十个关键参数助力数据库性能数倍提升
运维·mysql
cccccc语言我来了1 小时前
Linux(10)进程概念
linux·运维·服务器
伐尘1 小时前
【linux】查看空间(内存、磁盘、文件目录、分区)的几个命令
linux·运维·网络
Deitymoon1 小时前
linux——PV操作
linux
倔强的胖蚂蚁2 小时前
x2openEuler 辅助机完整部署教程
运维·云原生
原来是猿2 小时前
Linux进程信号详解(二):信号产生
linux·运维·服务器
chxii2 小时前
Nginx性能优化-压缩(返回头报文介绍)
运维·nginx·性能优化
Bert.Cai2 小时前
Linux cd命令详解
linux·运维
n 55!w !1083 小时前
IP-vlan实验报告
服务器·网络·tcp/ip