Sending command-line email attachments

It is often convenient to send email attachments from a command-line e-mail client noninteractively in UNIX.

uuencode may be used to send standard uuencoded attachments as well as base64 attachments (using uuencode's -m flag). The mutt e-mail client sends attachments in MIME format.

In Red Hat Linux, uuencode is part of the sharutils package.

Note that input_file and output_file below will be the attachment filename.

Using default uuencode format (choose from one of the formats below depending on your mail user agent):
uuencode input_file output_file | sendmail recipient(s)
uuencode input_file output_file | mail -s subject recipient(s)

uuencode input_file output_file | mailx -s subject recipient(s)

Using base64 format with uuencode (choose from one of the formats below depending on your mail user agent):
uuencode -m input_file output_file | sendmail recipient(s)
uuencode -m input_file output_file | mail -s subject recipient(s)

uuencode -m input_file output_file | mail -s subject recipient(s)

Using MIME attachments with mutt:
mutt -a attachment -s subject recipient(s) < "."

More information:
SHELLdorado - Sending files as email attachments

Back to brandonhutchinson.com.

Last modified: 12/28/2004