Sending attachement using mailx

Hi

I tried reading docs from this forum and googled it...but i couldnt get the answer for attaching a document in mail.

I need it to be the actual attachement not adding the content of the file to the body of the mail..

i used uuencode ...to encode the file but it is coming as a junk character in the mail body (actual mail received)

uuencode /tmp/tmp-mail.txt attach.txt | /usr/lib/sendmail -t -n -f root aemunathan.r@gmail.com


uuencode /tmp/tmp-mail.txt attach.txt | mailx -s "Test attachment" aemunathan.r@gmail.com



in a script taken from this forum i used this way.

#!/usr/bin/ksh

export MAILTO="aemunathan.r@gmail.com"
export SUBJECT="Mail Subject"
export BODY="/tmp/tmp-mail.txt"
export ATTACH="/aemu/CMW_A02_2.sql"
(
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 cat $BODY
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'$(basename $ATTACH)'"'
 echo "Content-Transfer-Encoding: base64"
 echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
 uuencode --base64 $ATTACH $(basename $ATTACH)
 echo '---q1w2e3r4t5--'
) | /usr/lib/sendmail $MAILTO

this resulted in uuencode illegal option base 64

another script i tried is

#!/bin/ksh

export TOADDR=aemunathan.r@gmail.com    
export FROMDIR=/aemu

cd ${FROMDIR}

( cat <<-TEXT
Hi,

Please find enclosed all of the text files found
in the directory ${FROMDIR} as of $(date).

Sincerly, $(grep root  /etc/passwd| cut -d: -f5)
TEXT

for FNAME in *.sql
do
   uuencode ${FNAME} ${FNAME}
done
) | mailx -s "${FROMDIR}/*.sql as of $(date)" ${TOADDR}

this resulted in junk charaters in the body of the mail

Any one help me out what mistake am doing here....

Thanks
Aemu

uuencode $ATTACH $ATTACH |mailx -s "SUBJECT" $MAILTO

Please try this one.....

Hi

Mail sending is ok but not the attachement.

am getting junk like this in the body of the mail...

Not all versions of mailx support MIME attachments.

Check to see if your version of mailx has a -m command line option. It it has, use that option to create a MIME attachment.

If not, you could use utilities such as mpack/munpack or mmencode to create a MIME attachment.

Hi

that also i tried initially. with -m option...my server does not support it...

do i need to install mpack...

i tried searching *encode* in my server from root directory....found only uuencode...nothing else....