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:




<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\"><head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">


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

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


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



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.)