Email multiple file attachment from Solairs / AIX / HP-UX UNIX/ Linux command line
Q. Hey quick question - How do I mail files from AIX / HP-UX UNIX as attachments from my shell scripts or command line?
A. If you have mutt mail client installed, use the mutt as described here.
If you don’t have mutt installed use the following command to email files as attachment from UNIX command / shell prompt / shell scripts.
Task: Email reports.tar.gz
Type uuencode command as follows:
$ uuencode reports.tar.gz reports.tar.gz | mailx -s "My Report" user@yourcorp.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
Type the command as follows;
$ (cat mymessage.txt; uuencode office.jpeg office.jpeg) | mail -s "Subject" user@my.yahoo.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" user@my.somewhere.com < /tmp/out.mail
Further readings:
- Use mutt command to send files as mail attachments under Linux / UNIX oses
- Please refer the the "uuencode" man page for more information.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Postfix block PDF or ZIP files attachments
- Linux send email from console
- FreeBSD send mail with attachments from command line / shell prompt
- Sending mail with Perl mail script
- Linux and UNIX Mail Command to send and receive mail
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: email attachmet command, mail attachments, mail client, mime attachment, mutt command, send attachment, sending attachment, sendmail attachment, shell scripts, smtp attachment, unix email multiple file attachment, unix script, uuencode, uuencode command



September 6th, 2007 at 1:37 pm
Hi, the information was quite helpful. I was unable to send an attachement along with mail body. The above combination of cat and mail command helped me.
Thanks,
March 5th, 2008 at 5:15 pm
Thank-you very much… exactly what I needed !
April 14th, 2008 at 9:39 pm
Thank you so much! I’ve been looking for something like this for a long time. I needed to send multiple attachments and was able to make a quick adjustment to do so:
$ 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.txt >> /tmp/out.mail
$ mail -s “Reports” user@my.somewhere.com < /tmp/out.mail
April 14th, 2008 at 10:27 pm
Jakki,
The faq has been updated to include your cat command.
June 20th, 2008 (3 weeks ago) at 6:02 am
hai,
while using uuencode i get some junk value in mail
Let me know why this is happening….