Shell – What are some better options for encoding email attachments than uuencode in a bash script

character encodingemaillinuxshell-script

I'm referencing my original post in which I was asking a question about argument placement pertaining to $2 $3 etc, and eventually ${@:2}. It was mentioned that there are better methods to encode email attachments.

Note, I used uname -or to figure out 2.6.32-400.26.3.el5uek GNU/Linux.

I used the command within a bash script to attach a file to an email, and have it in a couple other scripts as well. However, a few of our machines do not even support uuencode, so what are some better options for attaching files to emails than uuencode?

Best Answer

I prefer using mpack to send attachments as MIME

as in:

mpack -s "message" file email@example.com

Name

mpack - pack a file in MIME format Synopsis

mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c content-type ] file address ... mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c content-type ] -o outputfile file mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c content-type ] -n newsgroups file Description

The mpack program encodes the the named file in one or more MIME messages. The resulting messages are mailed to one or more recipients, written to a named file or set of files, or posted to a set of newsgroups.

Related Question