我在 CentOs 上使用 sendmail 实用程序来发送邮件。我无法为使用此实用程序发送的邮件设置主题行和添加附件。使用选项“-s”设置主题行不适用于 sendmail 实用程序。请说明将哪些选项与 sendmail 一起使用以实现这些目标。
最佳答案
sendmail
是一个低级实用程序。您必须自己编写额外的消息 header 。
也就是说,要在您添加的邮件正文之前添加主题行:
Subject: <your-subject>
还有一个新行将标题与正文分开。
同样,添加附件:
Subject: <your-subject>
Content-Type: multipart/mixed; boundary="-unique-str"
---unique-str
Content-Type: text/html
Content-Disposition: inline
<html-body here>
---unique-str
Content-Type: application; name=<attachment-mime>
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=<attachment-name>
<your base64-encoded attachment here>
---unique-str--
或者类似这样的东西(我没测试过)。
您可以通过查看大多数电子邮件客户端中可用的“显示原始”或“显示来源”选项来了解真实邮件的格式。这些选项将向您显示原始消息,您只需要构建类似的东西。
关于linux - 在 Linux 上使用 sendmail 实用程序时如何设置主题行和添加附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25843007/