使用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 [email protected]
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" [email protected]  

如果希望带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")"  [email protected]

参考文献:

相关推荐
whgjjim23 分钟前
docker迅雷自定义端口号、登录用户名密码
运维·docker·容器
tmacfrank1 小时前
网络编程中的直接内存与零拷贝
java·linux·网络
瀚高PG实验室4 小时前
连接指定数据库时提示not currently accepting connections
运维·数据库
QQ2740287564 小时前
Soundness Gitpod 部署教程
linux·运维·服务器·前端·chrome·web3
淡忘_cx4 小时前
【frp XTCP 穿透配置教程
运维
qwfys2004 小时前
How to configure Linux mint desktop
linux·desktop·configure·mint
南方以南_4 小时前
Ubuntu操作合集
linux·运维·ubuntu
冼紫菜5 小时前
[特殊字符]CentOS 7.6 安装 JDK 11(适配国内服务器环境)
java·linux·服务器·后端·centos
Chuncheng's blog6 小时前
RedHat7 如何更换yum镜像源
linux
爱莉希雅&&&6 小时前
shell脚本之条件判断,循环控制,exit详解
linux·运维·服务器·ssh