Attach a File to Message via Command Line

Here’s an example of an email attachment.

# uuencode my_binaryfile1 | mailx -s “Email binary as attachment” esofthub@esofthub.com

For multiple attachments, I use a mail client such as dtmail, Netscape or FireFox. But I’ve seen this done too.

# uuencode my_binaryfile1 my_binaryfile2 | mailx -s “Email binary as attachment” esofthub@esofthub.com

For NON-binary type files

Please note the ~r (tilde command followed by r)
# mailx esofthub@esofthub.com (hit enter)
Subject: End of Week Status Report (hit enter)
~rendofweekstatus.dat (hit enter)
~. (hit enter)
EOT

The above procedure (non-binary) works great for inline text files.

Also,

# cat endofweekstatus.dat | mailx -s “End of Week Status Report” esofthub@esofthub.com

Tags: , , , , ,