【问题标题】:linux mail adding content type headers not workinglinux邮件添加内容类型标头不起作用
【发布时间】:2014-04-22 20:50:10
【问题描述】:

我正在使用 ma​​il 命令从我的 linux 系统发送邮件。

我遇到的问题是邮件的内容类型始终为Content-Type: text/plain; charset=us-ascii

我正在发送 html 内容,它显示为纯文本。

这是我尝试过的

1)
body="From: me@example.org
To: me@gmail.com
Subject: MIME Test
Mime-Version: 1.0
Content-Type: text/html

<html>
<body>
This is a test.
</body>
</html>";

echo $body| mail -s "testing purpose" reciever@gmail.com

这没用

我把这个 html 放在 $tempfile 中一个名为 test.html 的文件中 并试图像这样执行

2)
mail -a 'MIME-Version: 1.0' -a 'Content-Type: text/html; charset=iso-8859-1' "server details" "receiver@gmail.com" < $tempfile

但没有任何效果,请就此向我提出建议(请仅使用邮件而不是 sendmail/mutt)。

【问题讨论】:

    标签: linux bash shell mailx


    【解决方案1】:

    试试

    echo "<b>HTML Message goes here</b>" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" foo@example.com
    

    How to send HTML email using linux command line

    【讨论】:

      猜你喜欢
      • 2015-12-22
      • 2013-08-21
      • 2022-09-26
      • 2016-01-01
      • 2017-04-30
      • 2016-06-19
      • 2023-03-14
      • 1970-01-01
      • 2018-07-22
      相关资源
      最近更新 更多