How do I set the subject line and add an attachment when using the Linux sendmail utility?

I am using the sendmail utility in CentOs to send mail. I am unable to set a subject and add an attachment for emails that are sent using this utility. Using the "-s" option to set the subject line does not apply to the sendmail utility. Explain what options to use with sendmail to achieve these goals.

+3


source to share


1 answer


sendmail

- low-level utility. You must compose additional message headers yourself.

That is, to add a subject line, before the body of the message you add:

Subject: <your-subject>

      

And a new line to separate headers from the body.



Similarly, add an attachment:

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--

      

Or something like this (I haven't tested it).

You can see how real messages are formatted by looking at the show original or show source options available for most email clients. These options will show you a raw message and you just need to create something like this.

+7


source







All Articles