I am using sendmail utility on CentOs to send mail. I am not able to set the subject-line and add attachment for the mails which are sent using this utility. Using option "-s" to set the subject line is not applicable for sendmail utility. Please tell what options to use with the sendmail for achieving thses objectives.
sendmail
is a low-level utility. You have to compose the extra message headers yourself.
That is, to add the subject line, before the body of the message you prepend:
Subject: <your-subject>
And a new line to separate the headers from the body.
Likewise, to add the 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 didn't test it).
You can see how real messages are formatted by looking at the "show original" or "show source" options available in most e-mail clients. Those options will show you the raw-message and you just need to build something similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With