sending attachement in mail

Hi ,
I am using the below code to send mail through a script which run as a cron job.

msgdate=`date +"%a, %e %Y %T %z"`
daemail=$(cat <<!
From: $from
To: $emailtarget
Subject: $subject
Mime-Version: 1.0
Content-Type: multipart/mixed;
Content-Disposition: inline
$priority

$CONTENT
!)

echo "$daemail" > msg.tmp
echo  >> msg.tmp
email=`cat msg.tmp`
echo "$email" | /usr/sbin/sendmail -t

If i want to send hi.csv as a attachment..how should the code be modified.
can someone help me which the code.

Thanks,
Ahamed.

Your date format is missing the month; I think you want:

msgdate=`date +"%a, %e %b %Y %T %z"`

Why are you using cat? Assign the string directly:

daemail="From: $from
To: $emailtarget
Subject: $subject
Mime-Version: 1.0
Content-Type: multipart/mixed;
Content-Disposition: inline
$priority

$CONTENT"

If you want to use sendmail, you'll have to uuencode the attachment.

I find the easiest way to send attachments in a script is to use alpine or mutt.

Check this link
How do I send email? - The UNIX and Linux Forums