Sending Email With Attachments From The Command Line

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 ~/;) | mail -s "Email Subject"
This will attach to the email and send it to


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


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

Cool. Cheers for the tip.

If mutt is configured, you can just:

echo 'The files are attached' | mutt -a filename -s 'Subject text here'

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.


OpenID accepted here Learn more about OpenID
Creative Commons License
This blog is licensed under a Creative Commons License.
Powered by Movable Type 5.02