Send HTML email from command line

Problem

Need to send an email from UNIX command line, that contains HTML content?



Solution

Most useful when generating statistics, etc – just spin round and spit out HTML table rows, through sendmail.



Example


Here is the code:


/usr/lib/sendmail -t
To:[email protected]
From:[email protected]
Subject:This is a test
MIME-VERSION:1.0
Content-Type: multipart/mixed; boundary="gc0y0pkb9ex"

--gc0y0pkb9ex
Content-type: text/html;charset="iso-8859-1"

<html><head><title>Test HTML mail</title></head>
<body>
<table border=1>
<tr><td align=center>test mail</td></tr>
<tr><td>This is an HTML email sent from UNIX command line!</td></tr>
</table>
</body></html>
.





Leave a Reply

Your email address will not be published. Required fields are marked *