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" email@example.com
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" firstname.lastname@example.org
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" email@example.com < /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.Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?