Problem with mailx attachment using uunendcode -m

We've been emailing uuencode'd PDF files as attachments with mailx for quite sometime with no problems. Recently we've expanded the volume and have intermittent problems with recipients unable to open the attachment. The same file can be successfully resent at a different time.

It's been suggested we move from basic uuencode to MIME/Base64. To accomplish that we added "-m" to uuencode. The file is Base64 encoded, but rather than being an attachment to the message, it's in the body of the message as the encoded text which of course is not acceptable.

This sends the email with the PDF file as an attachment

SUBJ=$1
SENDTO=$2                                                                       
ATTACH=$3                                                                       
BODY="$( cat mailit.txt )"                                                      
baseName=$( basename $ATTACH )                                                  
                                                                      
(echo "$BODY"; uuencode $baseName $ATTACH) | mailx -s "${SUBJ}" -inN -r "$SEMAIL" "$SENDTO"

This puts the encoded text into the body of the message

SUBJ=$1
SENDTO=$2                                                                       
ATTACH=$3                                                                       
BODY="$( cat mailit.txt )"                                                      
baseName=$( basename $ATTACH )                                                  
                                                                      
(echo "$BODY"; uuencode -m $baseName $ATTACH) | mailx -s "${SUBJ}" -inN -r "$SEMAIL" "$SENDTO"

Any suggested remedies would be MUCH appreciated.

TIA
Lee Carlson

I have used uuencode and mpack in the past for sending attachements as emails. The best method that I have found is to install the Perl mime lite library and write a Perl script for sending the email. There are plenty of options on how to send the email and you should be able to send it using MIME/Base64. If Perl isn't an option, check to see if mpack is installed. Perl would be the best option though.

http://www.perlmonks.org/index.pl?node_id=1071064