源码

Mailx发送html消息


参见英文答案 > Sending HTML mail using a shell script????????????????????????????????????11个
>????????????How do I send a file as an email attachment using Linux command line?????????????????????????????????????26个
我想用Mailx发送一条HTML消息.当我尝试以下命令时

mailx -s "Subject"  [email protected]  < 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")" [email protected]  < email.html

给出了这个结果:

From: [email protected]
To: [email protected]
Subject: This is the subject
Content-Type: text/html
Message-ID: <538d7b66.Xs0x9HsxnJKUFWuI%[email protected]>
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.当我尝试在网络邮件中显示消息时,我得到一个空白页面…

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/mailxfasonghtmlxiaoxi.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 16, 2019 at 11:01 下午

热评文章