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”

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”

For NON-binary type files

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

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


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

Tags: , , , , ,