Sendmail Attachment

With mutt you can simply use:

echo "This is the message body" | mutt -a "/path/to/file_to_attach" -s "subject of message" -- [email protected]

Using mail command:

mail -a /opt/emailfile.eml -s "Email File" [email protected] < /dev/null

-a is used for attachments.

You can use SendEmail:

sendemail -t [email protected] -m "Here is the file." -a attachmentFile

Posting the solution that worked for me in case it can help anyone else, sorry it's so late.

The most reliable way I found for doing this was to include the attachment as base64 in the eml file itself, bellow is an example of the eml contents.

Note 01 : the base64 for the file comes from running the base64 command on linux using the attachment as an argument (should work with any base64 tool)

Note 02 : the string used for the boundary is just nonsense using the date and random upper case letters

Filename : emlfile.eml

From: Sender <[email protected]>
To: [email protected]
CC: [email protected]
Disposition-Notification-To: [email protected]
Subject: Generic Subject
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="19032019ABCDE"

--19032019ABCDE
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Generic Body Copy

--19032019ABCDE
Content-Type: application;
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="MyPdfAttachment.pdf"

*base64 string goes here (no asterix)*

--19032019ABCDE--

Then the filename.eml file can be sent using the command and it will include the attachment

# /usr/sbin/sendmail -t < filename.eml