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

参考文献:

相关推荐
ltl11 分钟前
序列化格式深度对比:Protobuf、FlatBuffers、Cap’n Proto
linux
lengjingzju14 分钟前
编译与调试完全指南—第17章 总结
linux
ltl21 分钟前
容器网络性能真相:veth vs macvlan vs eBPF 数据面
linux
Elastic 中国社区官方博客1 小时前
ES95:面向 Elasticsearch 时间序列指标的自适应压缩
大数据·运维·elasticsearch·搜索引擎·架构·全文检索
80s7772 小时前
动态ip和静态ip有什么区别
服务器·网络·tcp/ip
mqiqe2 小时前
AgentScope Java 2.0 Agent 状态存储(AgentStateStore)深度解析:构建可恢复、可扩展的智能体运行时
java·运维·网络
mennekes2 小时前
数据中心安全配电设备如何选择?
运维·人工智能·科技·安全·制造
CSDN121103 小时前
麒麟 V10 安装 Node-RED、IEC 104 协议插件及界面汉化
linux·编辑器·vim
开始学AI4 小时前
Codex2API Docker 使用宿主机代理:OAuth Token 兑换 403 问题排查与解决方案
运维·docker·容器
晨枫阳4 小时前
@changesets/cli是什么?哪些情况下需要使用?怎么使用
linux·运维·ubuntu