clarkseth
clarkseth

Reputation: 229

[KSH]How create a html mail using shell script?

i need to use a ksh language, for create a script to forward an e-mail, with html content in the body, could you help me with a tutorial, or a example easy script?

Thanks in advance.

Upvotes: 0

Views: 2581

Answers (1)

Drew Khoury
Drew Khoury

Reputation: 1390

http://unixnair.blogspot.com.au/2011/09/how-to-send-email-with-html-formatting.html

#!/usr/bin/ksh
# Script to send html email
# Written by Madhu

FROM="[email protected]"
TO="[email protected]"
SUBJECT="This email has html contents"
CONTENTS="/home/madhu/scripts/mail_text.html"
HEADER="From: ${FROM}                             \
\nTo: ${TO}                                     \
\nSubject: \"$SUBJECT\"                              \
\nContent-Type: text/html; charset=us-ascii   \
\nContent-Transfer-Encoding: 7bit                  \
\nMIME-Version: 1.0"
#echo $HEADER;
( echo $HEADER; cat $CONTENTS ) | /usr/sbin/sendmail -t

Upvotes: 1

Related Questions