Wednesday, May 19, 2010

Sending a mail with an attachment

I always end up googling this; so thought I'd add it to my blog - leaving me only one place to look!

To mail a single attachment (with no message):

uuencode filename.txt.gz filename.txt.gz | mailx -s subject email_address

To mail a single attachment with a message:

(cat message.txt; uuencode filename.txt.gz filename.txt.gz) | mailx -s subject email_address

To mail multiple attachments:

(cat message.txt; uuencode filename01.txt.gz filename02.txt.gz && uuencode filename02.txt.gz filename02.txt.gz) | mailx -s subject email_address