Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Mail a file as an attachment from the UNIX prompt (See related posts)

   1  uuencode file.txt file.txt | mail email@address.com

Comments on this post

rikkus posts on Aug 30, 2005 at 13:51
If you prefer to use MIME, mime-construct can be used:

   1  
   2  mime-construct \
   3    --to       "person@example.com" \
   4    --subject  "Your computer" \
   5    --string   "Your computer is on fire" \
   6               --type text/plain --file-attach extinguishing_howto.txt
gabe posts on Apr 13, 2007 at 12:14
If you have mutt installed, you can send mail as follows:
   1  
   2   mutt -s "This a subject"  \
   3        -a Attached_File.txt \
   4        recipient@email.com  < Email_Body.txt


With mutt, you can add many attachments (not sure if there is a limit) and you don't have to mess with uuencode and mailx. Attachments are attached as one would expect. This functionality can be wrapped easily in a script that so that you can make use of environment/script variables for the arguments.

You need to create an account or log in to post comments to this site.


Click here to browse all 5309 code snippets

Related Posts