mailx发送html,Mailx发送html消息

mailx -s "Subject" user@gmail.com < email.html

我以纯文本格式获取了email.html的内容.在消息中,标题Content-Type设置为text / plain. -a选项尝试发送文件,因此我没有找到如何修改标头.这个answer几乎可以工作,它将Content-Type设置为text / html,但不能替换默认的Content-Type,即text / plain.

mailx -s "$(echo -e "This is the subject\nContent-Type: text/html")" user@gmail.com < email.html

给出了这个结果:

From: send@gmail.com

To: user@gmail.com

Subject: This is the subject

Content-Type: text/html

Message-ID: <538d7b66.Xs0x9HsxnJKUFWuI%maikeul06@gmail.com>

User-Agent: Heirloom mailx 12.4 7/29/08

MIME-Version: 1.0

boundary="=_538d7b66.z5gaIQnlwb1f/AOkuuC+GwF1evCaG/XIHQMbMMxbY6satTjK"

This is a multi-part message in MIME format.

--=_538d7b66.z5gaIQnlwb1f/AOkuuC+GwF1evCaG/XIHQMbMMxbY6satTjK

Content-Type: text/plain; charset=us-ascii

Content-Transfer-Encoding: 7bit

Content-Disposition: inline

Helo wolrd

PS:我也试过用uuencode.当我尝试在网络邮件中显示消息时,我得到一个空白页面…

解决方法:

如果您的mailx命令支持-a(追加标题)选项,这很容易:

$mailx -a 'Content-Type: text/html' -s "my subject" user@gmail.com < email.html

如果没有,请尝试使用sendmail:

# create a header file

$cat mailheader

To: user@gmail.com

Subject: my subject

Content-Type: text/html

# send

$cat mailheader email.html | sendmail -t

标签:html,linux,email,mailx

来源: https://codeday.me/bug/20190916/1807429.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值