Send Email From Linux Server As Html - Content Type And Html Tags Also Visible In Email
I am trying to send an email as html. #!/bin/sh #MAIL_LIST='gangadhar.n@xx.com' MAIL_SENDER=foo fnSendEmail(){ echo ${BODY}| mail -r $MAIL_SENDER -s '$(echo '$MAIL_SUBJECT\n
Solution 1:
I have done it using sendmail
#MAIL_LIST1="Gangadhar.N@xx.com"
MAIL_SENDER=dap
fnSendEmail(){
(
echo To: $MAIL_LISTecho Cc: $MAIL_LISTecho From: dap53
echo"Content-Type: text/html; "echo Subject: $MAIL_SUBJECTechoecho$BODY
) | /usr/sbin/sendmail -t
}
MAIL_SUBJECT="Test email"
BODY="<html><body>Sample</body></html>"
fnSendEmail $BODY$MAIL_SENDER$MAIL_SUBJECT$MAIL_LIST
Solution 2:
Use option -a to append content-type header, -s is for subject, change your fnSendEmail to following it should work
fnSendEmail(){
echo${BODY}| mail -r $MAIL_SENDER -a "Content-type: text/html" -s "$(echo "$MAIL_SUBJECT\n")""$MAIL_LIST"
}
Post a Comment for "Send Email From Linux Server As Html - Content Type And Html Tags Also Visible In Email"