【问题标题】:Bash: Sending HTML with an attached file?Bash:发送带有附件的 HTML?
【发布时间】:2012-05-07 09:01:13
【问题描述】:

我正在寻找一种从 bash 发送带有附件的 HTML 电子邮件的方法。 我已经尝试了以下行,但它不能 100% 工作。以下行发送了一封 HTML 电子邮件,但没有附件:

( cat body.html ; uuencode in-attachfile.txt out-attachfile.txt ) | mail -s "$(echo -e "my subject\nContent-Type: text/html")" foo@example.com

如果我删除 Content-Type: text/html 以表明这是一封 HTML 电子邮件,则附件有效:

( cat body.html ; uuencode in-attachfile.txt out-attachfile.txt ) | mail -s "$(echo -e "my subject")" foo@example.com

我怎样才能两者兼得?

谢谢

【问题讨论】:

    标签: html linux bash email attachment


    【解决方案1】:

    试试这个:

    ( cat body.html; uuencode in-attachfile.txt out-attachfile.txt ) | mail -s "my subject" -a "Content-Type: text/html" foo@example.com
    

    您可能希望使用 MIME 发送附件(例如,通过 mutt)。请参阅this 了解更多信息。

    【讨论】:

    • 我的mail 没有-a 选项...我正在运行centOS。
    • 你可以使用sendmail吗?另外,我认为可以使用多部分 mime 类型在 html 中嵌入文档。尝试查看包含您需要的所有内置功能并从那里构建的原始文档。祝你好运。
    • @shellter 你能给我一个带有 sendmail 的 MIME 的例子吗?谢谢。
    • @Dennis 我无法在这台机器上安装第 3 方软件,例如 mutt
    猜你喜欢
    • 2015-10-16
    • 2013-11-26
    • 2012-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多