Attaching files with the mail command

I have been asked more than a few times about attaching files to e-mails from the command line. Here is the way I do it. You can use this with both mail and mailx.

NOTE: you will need uuencode to accomplish this.

uuencode /path/2/file file_name | mail -m -s "subject" user@domain.com

or

uuencode /path/2/file file_name | mailx -m -s "subject" user@domain.com


I am sure there are more ways to do this. But this has always worked for me.

Comments