Display both html and plain text in email in shell script

Hi,

I want to display both html and plain in email in my script.

i tried the below code

code:

export MAILTO="ssi@a.com"
export CONTENT1="$htmlfile"
export CONTENT2="$plainfile"
export SUBJECT="INFO "
export MAILFROM="si@a.com"
(
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/alternative; boundary=boundary-content_example";
echo "Content-Disposition: inline"
echo "--boundary-content_example"
echo "Content-Type: text/html"
cat $CONTENT
 
echo "--boundary-content_example"
echo "Content-Type: text/plain"
cat $CONTENT

echo "--boundary-content_example--"

) | sendmail -f $MAILFROM  $MAILTO

this is not working :wall:. I can see html page only no plaintext in email..

Please suggest me how to display both. :confused:

You cat cat'ing the same var/file for both.

Did you want the files as attachments? Why not just send the email twice?

Hi
You can try to cat for display as text file...

<PRE> `cat file` </PRE>

<PRE> tag display the file as it is....

When you <pre> you need to escape [<>'"&] like & to &, which sed can do.

$ cat mysrc/txt2html
#!/usr/bin/sed -f
 
s/\&/&/g
s/"/\&quot/g
s/>/\>/g
s/</\</g
s/'/\'/g
 
$