![使用mailx发送html](https://linux22.com/image/18144/%E4%BD%BF%E7%94%A8mailx%E5%8F%91%E9%80%81html.png)
我想使用 mailx 从主机发送 html 文件,但不是将其解释为 html,而是将其作为文本(html 代码)发送出去。有没有办法将其作为 html 发送?
(cat <<EOCAT
Subject: TEST email
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline
EOCAT
header
cat $MSGFILE
footer
) | mailx -r [email protected] [email protected]
答案1
您需要将其设为多部分/混合消息、边界等等。
( cat <<EOCAT
MIME-Version: 1.0
From: $from
To: $to
Cc: $cc
Subject: TEST email w/ HTML
Content-Type: multipart/mixed; boundary=NextPart_0123456789
Content-Transfer-Encoding: 7bit
--NextPart_0123456789
Content-Type: text/html
EOCAT
cat header.html
cat html_message_body.html
cat footer.html ) | mailx -r [email protected] [email protected]