shell send html email

I know how to send an email with sendmail in a shell script.

I know how to send an email with an attachment in a script.

But im trying to send an email and need to set Content-Type to text/html and insert a file as the body and not attachment.

Send email with file as attachment:

#!/bin/bash
 
ATTFILE=$1
ATTNAME=$1
MAILTO=me@home.com
MAILFROM=someone@mail.com
 
( cat <<HERE; uuencode "${ATTFILE}" "${ATTNAME}" ) | sendmail -oi -t
From: ${MAILFROM}
To: ${MAILTO}
Subject: Requested file attached $ATTNAME
 
HERE
 

How can I change this to put the ATTFILE directly in the body?

Im pretty sure it will take Content-Type like this:

.
.
From: ${MAILFROM}
To: ${MAILTO}
Content-Type: text/html
.
.
 

Thanks....

It might work if you change this line:
( cat <<HERE; uuencode "${ATTFILE}" "${ATTNAME}" ) | sendmail -oi -t
to:
( cat <<HERE; < "${ATTFILE}" ) | sendmail -oi -t

I'm not too sure about the order of appearance (either the header or the attachment coomes first, I'm not sure...

This still make the file an attachment with a .dat filename.

FYI: this is on a HP-UX system with Korn shell.

I figured it out:

( cat <<HERE; cat /path/to/file ) | sendmail -oi -t
From: ${MAILFROM}
To: ${MAILTO}
Subject: Some subject
Content-Type: text/html

HERE

Strictly speaking you should also have MIME-Version and Content-Transfer-Encoding headers. MIME-Version is simply 1.0, there has never been any other version; for Content-Transfer-Encoding, 7bit is appropriate if the content is plain 7-bit ASCII text with no long lines (longer than 1024 characters IIRC). (If it's not plain 7-bit ASCII you should also define the character set in Content-Type.)

Some versions of cat will accept standard input as an argument, so you can say

cat - /path/to/file <<HERE | sendmail -oi -t
From: ${MAILFROM}
To: ${MAILTO}
Subject: Same subject
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

HERE