Hey quick question - How do I mail files from IBM AIX / HP-UX Unix as attachments from my shell scripts or command line?
If you have mutt email client installed, try the mutt command as described here. If you don't have the mutt command installed, use the following command to email files as attachment from UNIX command prompt or shell scripts.
Task: Email reports.tar.gz File
Type the uuencode command as follows:
uuencode reports.tar.gz reports.tar.gz | mailx -s "My Report" firstname.lastname@example.org
Please note that the file name "reports.tar.gz" appears twice on the uuencode command line. You must use same name twice.
Task: Email new office photo along with text message read from a file
Type the command as follows;
(cat mymessage.txt; uuencode office.jpeg office.jpeg) | mail -s "Subject" email@example.com
Task: Send multiple attachments in a single email
Type the command as follows:
$ uuencode r1.tar.gz r1.tar.gz > /tmp/out.mail
$ uuencode r2.tar.gz r3.tar.gz >> /tmp/out.mail
$ uuencode r3.tar.gz r3.tar.gz >> /tmp/out.mail
$ cat email-body.txt >> /tmp/out.mail
$ mail -s "Reports" firstname.lastname@example.org < /tmp/out.mail
- Use mutt command to send files as mail attachments under Linux / UNIX oses
- Please refer the the "uuencode" man page for more information.
Page last updated at 12:33 AM, April 18, 2012.