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.Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop