Easiest way to email file via command line in *nix?

Assuming it's a binary attachment:

uuencode [filename] [filename] | mail -s [subject] [recipient address]

You don't need to bother with the UUencoding if it's just a text file, eg:

mail -s [subject] [recipient address] < [filename]

Most *NIXes have mail and uuencode, so this should work pretty much anywhere.


Using mutt, you can:

mutt -z -a <file> -s <subject> -- [email protected]

Or, if you don't want to type a body:

mutt -z -a <file> -s <subject> -- [email protected] < /dev/null


"sendEmail is a lightweight, command line SMTP email client. If you have the need to send email from a command line, this free program is perfect: simple to use and feature rich. It was designed to be used in bash scripts, batch files, Perl programs and web sites, but is quite adaptable and will likely meet your requirements. SendEmail is written in Perl and is unique in that it requires NO MODULES. It has an intuitive and flexible set of command-line options, making it very easy to learn and use. [Supported Platforms: Linux, BSD, OS X, Windows 98, Windows NT, Windows 2000, & Windows XP]"

I've used it before and really liked it. You can attach files with the -a option.