html - Bash:发送带有附件的 HTML?

标签 html linux bash email attachment

我正在寻找一种从 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

我怎样才能两者兼得?

谢谢

最佳答案

试试这个:

( 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获取更多信息。

关于html - Bash:发送带有附件的 HTML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10479340/

相关文章:

linux - 自动化 bash 脚本

php - 为什么无法访问我的网站(在 Wordpress 中)?

linux - 从日志文件中解析信息并查询进程表

linux - 如何提取以特定字符开头的标题行(忽略前导空格)?

Bash波浪号在某些参数中没有扩展,例如--home_dir=~

linux - 在 bash 脚本中使用并行处理分组的输入文件

html - 如何用 aside 隐藏父 div 之外的内容?

html - 如何从阻塞操作发送 WebSocket 事件? (需要设计建议)

javascript - Node JS 抓取 html 字符串中的第一张图片

node.js - Windows Linux 子系统命令不执行任何操作并且静默失败