Problem in sending inline html with an attachment using sendmail

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=border
--border
Content-Type: text/html
Content-Disposition: inline
<html><body><h2>This text should be displayed with html formatting</h2></body></html>
--border
Content-Type: text/plain
Content-Disposition: attachment
This text should be attached
--border--

The above is the content of the file "a.txt". When the below command is executed, the mail sent has no inline text and no attachment. Please help!

cat a.txt | /usr/bin/sendmail asdf@asdf.com

Try this..

echo "To: <mail-id's>" >> output_file
echo "Subject: <subject content>" >> output_file
echo "Mime-Version: 1.0" >> output_file
echo 'Content-Type: multipart/mixed; boundary="GvXjxJ+pjyke8COw"' >> output_file
echo "Content-Disposition: inline" >> output_file
echo "" >> output_file
echo "--GvXjxJ+pjyke8COw" >> output_file
echo "Content-Type: text/html" >> output_file
echo "Content-Disposition: inline" >> output_file
cat <your inline text content> >> output_file
echo "" >> output_file
echo "--GvXjxJ+pjyke8COw" >> output_file
echo "Content-Type: text/plain" >> output_file
echo "Content-Disposition: attachement; filename=<attachment file with extension>" >> output_file
echo "" >> output_file
echo "" >> output_file
cat <attachment file> >> output_file
cat output_file | /usr/lib/sendmail -t
2 Likes

Jayan,

Thanks for a very useful post...additional question: How can I work some body test into the reference file? Have tried a number of combinations that either break the attachment and put it inline as the body or attach the file I need, but ignore any attempts to add message body text. Is this done in Line 10 where <your inline text content> is?

Regards,

gdsmith