Wednesday, March 21, 2012

Unix commands for email with attachments

To send simple email (eg. a file content as body):

# cat /tmp/FILE1 | mailx -s "Replace it with actual subject" unixgeek@somecompany.com


To send email with attachment (eg. a file as attachment):

# (uuencode /tmp/FILE1 /tmp/FILE1 ) | mailx -s "Replace it with actual subject" unixgeek@somecompany.com


To send email with multiple attachments (eg. a file as attachment):

# (uuencode /tmp/FILE1 /tmp/FILE1 && uuencode /tmp/FILE2 /tmp/FILE2 ) | mailx -s "subject-line" unixgeek@somecompany.com

No comments: