html - 使用 mailx 发送带有 HTML 正文和附件的电子邮件

标签 html linux email attachment mailx

我目前正在使用 mailx 从我的脚本发送 html 格式的邮件:

cat body.html | /usr/bin/mailx -a "From: Me <me@domain>" -a "Content-type: text/html" -s "My subject" $RECIPIENTS

现在我想添加一个附件(png 图像),但我不知道如何添加。 我想在转向 mutt 或其他东西之前尝试使用 mailx。 非常感谢

最佳答案

如果您的要求很简单,您可以使用裸Sendmail。这不是我特别推荐的东西,但因为你想避免 mutt...

# Now that we actually concatenate two files (well, stdin and a file),
# we are no longer eligible for a Useless Use of Cat Award
( cat - body.html <<HERE
Subject: My subject
Mime-Version: 1.0
Content-type: multipart/related; boundary="foooobar"

--foooobar
Content-type: text/html

HERE

cat <<HERE

--foooobar
Content-type: image/png
Content-disposition: inline
Content-transfer-encoding: base64

HERE

base64 image.png

echo; echo '--foooobar--' ) | sendmail -oi $RECIPIENTS

我确实希望有一个简单的标准实用程序来实现这一点,但可惜的是,有很多,或多或少相互不兼容且模糊。再说一遍,如果您可以使用 mutt,那么这可能是您所期望的最广泛支持和标准的工具。

关于html - 使用 mailx 发送带有 HTML 正文和附件的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22308035/

相关文章:

linux - 是否有像 Git 一样的 SVN 交互式提交菜单 --interactive?

linux - 系统挂起可能与 "clocksource tsc unstable"相关?

linux - 如何将 cuDNN 更新到新版本?

email - SendGrid SMTP API : Multiple e-mails to the same recipient

email - Ubuntu exim4 - 配置设置和垃圾邮件过滤器

javascript - Internet Explorer 中的图像数据集

HTML、CSS 内联 block Div 跳出位置

css - float 用作内联样式,但当我将其移至外部样式表时则不起作用

javascript - 如何查看哪些元素仍在加载并阻碍 window.onload 触发?

iphone - 是否可以访问 iPhone 中的联系人信息屏幕?