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

参考文献:

相关推荐
matlab的学徒1 分钟前
Web与Nginx网站服务(改)
linux·运维·前端·nginx·tomcat
Insist7536 分钟前
prometheus安装部署与alertmanager邮箱告警
linux·运维·grafana·prometheus
BAGAE37 分钟前
MODBUS 通信协议详细介绍
linux·嵌入式硬件·物联网·硬件架构·iot·嵌入式实时数据库·rtdbs
灿烂阳光g41 分钟前
SELinux 策略文件编写
android·linux
xqlily1 小时前
Linux操作系统之Ubuntu
linux·运维·ubuntu
阿部多瑞 ABU1 小时前
《基于国产Linux的机房终端安全重构方案》
linux·安全
倔强的石头1061 小时前
【Linux指南】Makefile入门:从概念到基础语法
linux·运维·服务器
ajassi20001 小时前
linux C 语言开发 (七) 文件 IO 和标准 IO
linux·运维·服务器
程序猿编码2 小时前
基于 Linux 内核模块的字符设备 FIFO 驱动设计与实现解析(C/C++代码实现)
linux·c语言·c++·内核模块·fifo·字符设备
一只游鱼2 小时前
Zookeeper介绍与部署(Linux)
linux·运维·服务器·zookeeper