【问题标题】:send html content using mail command使用 mail 命令发送 html 内容
【发布时间】:2014-12-08 03:17:03
【问题描述】:

我尝试使用邮件命令发送 html 文件,但邮件内容对齐不起作用。

这是用于发送邮件的命令

/bin/mail -s "$(echo -e "log - $date\nFrom: ABC \n";)" abc@gmail.com /test

经过搜索,发现需要在表头添加“Content-Type”。所以我已将它添加到标题中并且它有效,但是 From 标题不起作用并且邮件上显示了一些附加信息。

这是我用来发送邮件的命令:

/bin/mail -s "$(echo -e "log - $datet\nContent-Type: text/html\nFrom: ABC \n";)" abc@gmail.com /test

添加 content-type 时邮件上显示的附加信息如下: 来自:ABC 用户代理:Heirloom mailx 12.4 7/29/08 MIME 版本:1.0 内容类型:文本/纯文本; charset=us-ascii Content-Transfer-Encoding:quoted-printable = =20

谁能告诉我如何使用带有上述所有选项的邮件命令发送 html?

【问题讨论】:

  • 感谢您的回复。我已经看过这个帖子了。我也尝试过使用 mailx 命令,但出现内容类型错误:mailx -a 'Content-Type: text/html' -s "Subject" abc@gmail.com
  • 该错误表明您的mailx 版本将-a 视为附件而不是附加标头。哪个操作系统和哪个版本的 mailx?
  • 更新:链接问题中的第一个答案清楚地表明mailx 的版本不止一个,您需要一个“来自 Ubuntu 上的 mailutils 或 Debian 的 bsd-mailx”
  • 我使用的是 CentOS 6.5

标签: html email


【解决方案1】:

请改用mutt。看到这个问题:Send Html page As Email using "mutt"

这个问题怎么做,但你需要一个支持添加标题的mail 版本:https://unix.stackexchange.com/questions/15405/how-do-i-send-html-email-using-linux-mail-command

如果您的 Linux 发行版没有,请从 http://mailutils.org/ 下载 mailutils 的源代码并编译它们。看到这个问题:https://superuser.com/questions/243152/how-to-send-email-message-content-as-html-rather-than-plain-text

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-12
    • 2016-08-09
    • 2011-09-27
    • 2014-12-04
    • 1970-01-01
    相关资源
    最近更新 更多