I'm using linux redhat 7. Currently I have a shell program that will send an email with an attachment, below are the codes:
echo $1
echo $2
mailto=$2
export mailto
/usr/lib/sendmail -f
user@server.com -v $mailto <<EOF
To:$mailto
Cc:
Subject: Test.
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="==Porsche====================="
--==Porsche=====================
Content-Type: text/plain; charset="us-ascii"
Some text message
--==Porsche=====================
Content-Type: application/octet-stream; name="${1##*/}"
Content-Transfer-Encoding: binary
Content-Disposition: attachment; filename="${1##*/}"
`cat $1`
--==Porsche=====================--
EOF
Using the above code, I can send an email with some text and a text file attachment. Now that I want to send an excel file attachment, I made the following changes:
1) Content-Type: application/vnd.ms-excel; name="${1##*/}"
2) Content-Transfer-Encoding: base64
However this doesn't work. The actual file received is an invalid excel file. Anybody can help me on this? Thanks.
Regards,
Alfred