Question : Send two files in email as attachment in unix shell scripting using ksh

Hi,
 I have shell script program to send a file as attachment. Here is the shell script program.
(

 echo "From: $MAILFrom"

 echo "To: ${V_MAIL_TO}"

 echo "Subject: $SUBJECT  Ran On`date`"

 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/sbin/sendmail -t ${V_MAIL_TO}

Currently this code is sending one file as attachment. How to modify the same code to send two or more files as attachment?

Thanks in advance.
-Plkj

Answer : Send two files in email as attachment in unix shell scripting using ksh

That's correct. I've tested it on Linux with some changes (I have no uuencode there, so lines with uuencode replaced by "cat" of text files, and 'Content-Type: application' lines thus removed).
And yes, it should work.

The reason the same boundary used everywhere is that the boundary is defined for the whole mail only once, and separates body from each attachment, and then finalizes the email with "--" appended.
Random Solutions  
 
programming4us programming4us