我想用 Mailx 发送 html 消息。当我尝试以下命令时
mailx -s "Subject" user@gmail.com < email.html
我以纯文本形式获取 email.html 的内容。在消息中,标头 Content-Type 设置为 text/plain。-a 选项尝试发送文件,所以我不知道如何修改标题。这个答案几乎奏效了,它很好地将 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
<html>
<body>
<p>Helo wolrd</p>
</body>
</html>
PS:我也尝试过使用 uuencode。当我尝试在网络邮件中显示消息时,我得到一个空白页......