How to send email HTML + PDF attachment?

I am attempting to write a script where I can pass in parameters ( to , from, the location of a pdf attachment ) and send an email that has HTML for the body content and a PDF as an attachment.

I have failed to achieve this with sendmail and mutt. I recently found this.

If there are any other ideas, let me know. I could do this with Java or another programatic language but wanted to try and do this from the command line in a bash shell script first.

using mutt to send html email with an attachment - Stack Overflow

Are you getting any errors? Show us your script, how you are using it and any errors you see.

--ahamed

Update attachment file name (pdf) and body file name (HTML) in the respective export statements

export MAIL_FROM=""
export MAIL_TO=""
export MAIL_CC=""
export SUBJECT=""
export MSG_BODY=""
export ATTACH=""
 
(
echo "From: ${MAIL_FROM}"
echo "To: ${MAIL_TO}"
echo "Cc: ${MAIL_CC}"
echo "Subject: ${SUBJECT}"
echo 'MIME-Version: 1.0'
echo 'Content-Type: multipart/mixed; boundary="aXs$dp%^x�#991"'
echo '--aXs$dp%^x�#991'
echo 'Content-Type: text/html\n'
awk '{print $0 "<BR>"}' ${MSG_BODY}
echo '--aXs$dp%^x�#991'
echo 'Content-Type: application/pdf; name="'$(basename $ATTACH)'"'
echo 'Content-Transfer-Encoding: uuencode'
echo 'Content-Disposition: attachment; filename="'$(basename ${ATTACH})'"'
uuencode ${ATTACH} $(basename ${ATTACH})
) | sendmail -t