Sending Email With Attachments From The Command Line

| | Comments (4) | TrackBacks (0)
It's often handy to send email from the command line using mail, however it isn't very obvious how to attach files to the resulting email. To do it, you just require uuencode. In both Debian and Red Hat based distributions, this will be in the sharutils package. To send attachment with the email run the following command:
(echo Email Body Text; uuencode ~/file1.zip file1.zip;) | mail -s "Email Subject" recipient@example.com
This will attach file1.zip to the email and send it to recipient@example.com.

0 TrackBacks

Listed below are links to blogs that reference this entry: Sending Email With Attachments From The Command Line.

TrackBack URL for this entry: http://blog.moybella.net/cgi-bin/mt-tb.cgi/54

4 Comments

Steve Burke said:

Thunderbird picks up the attachment nicely. Pine or Mutt doesn't :-/

Steve,

Hadn't tried sending uuencoded messages to them before. However there is a way around it using mpack.

mpack -s "Subject" -d file.with.body -c application/octet-stream file.to.attach recipient@example.com

Steve Burke said:

Cool. Cheers for the tip.

Anthony Greene said:

If mutt is configured, you can just:

echo 'The files are attached' | mutt -a filename -s 'Subject text here' recipient@example.com

Leave a comment

About this Entry

This page contains a single entry by Niall Donegan published on April 24, 2007 1:46 PM.

Why Excel Ends Up Being Used As A Database was the previous entry in this blog.

Carlow Municipal Wifi Network is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01