About Linux FAQ

Browse More FAQs:

Email multiple file attachment from Solairs / AIX / HP-UX UNIX/ Linux command line

Posted by Vivek Gite [Last updated: April 14, 2008]

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:

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:

Discussion on This FAQ

  1. Syed Says:

    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,

  2. Steve Says:

    Thank-you very much… exactly what I needed !

  3. Jakki Says:

    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

  4. vivek Says:

    Jakki,

    The faq has been updated to include your cat command.

  5. sathish Says:

    hai,

    while using uuencode i get some junk value in mail

    Let me know why this is happening….

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!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.