Not sure if anyone around here can help me with this but I'm struggling w/ using ksh (Korn Shell) on a Red Hat machine to send an HTML message with a simple txt file attachment...

Here's what I have so far:

Code:
#!/bin/ksh

attachment="archive/$logfilename"

subject="Foobar"
email_to="mister.foo@bar.com"
email_from="foo@bar.com"

email_msg="
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<title>Foobar</title>
</head>

<body>
<div>
Test
</div>
</body>
</html>
"

cat <<- _EOF_ | /usr/lib/sendmail -oi -t
From: $email_from
To: $email_to
Subject: $subject
Date: $(date +%Y%m%d)
Return-Path: help@foobar.net
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MAIL_BOUNDARY";
Content-Transfer-Encoding: 7bit

--MAIL_BOUNDARY
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

$email_msg

if [[ -n $attachment && -f $attachment && -r $attachment ]]; then
--MAIL_BOUNDARY
Content-Type: application/html; name="$logfilename";
Content-Disposition: attachment; filename="$logfilename";

fi

_EOF_

--MAIL_BOUNDARY
When I send the message, I get it and there is a txt file attached, but the contents is never correct because it outputs shell code as the contents of the attachment--which tells me I have my MIME headers screwed up.

Any input / feedback is appreciated. The txt file is just a log file for a process we have.

Do I have to somehow use ksh to grab the contents of the file, store it in a variable, and then echo that variable inside the attachment area??? Pretty lost right now... (ksh is something I'm not very familiar with.)