Send HTML email from command line


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



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



Here is the code:

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

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

<html><head><title>Test HTML mail</title></head>
<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>



[tags], Unix Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

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