当前位置:   article > 正文

使用linux的mail命令发送html格式的邮件

使用linux的mail命令发送html格式的邮件

1、关闭本机的sendmail服务或者postfix服务

#执行下面的命令,各位大侠都对号入座吧
#sendmial
service sendmail stop
chkconfig sendmail off
#postfix
service postfix stop
chkconfig postfix off

#再狠一点就直接卸载吧..
yum remove sendmail
yum remove postfix
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

2、然后修改/etc/mail.rc,在文件末尾增加以下内容,指定邮箱和授权码

set from=123456@qq.com
set smtp=smtp.qq.com  
set smtp-auth-user=123456
set smtp-auth-password=你的授权码
set smtp-auth=login  
  • 1
  • 2
  • 3
  • 4
  • 5

3、授权码的获取方式
在这里插入图片描述

4、然后通过命令来发送邮件

echo  hello word | mail -s " title" 123456@qq.com  
  • 1

如果希望带html格式的内容,可以这么发:

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
  • 1

参考文献:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/828440
推荐阅读
相关标签
  

闽ICP备14008679号