This is the code that I use to mail a html table from one of my sites
The $headers TO field is commented out because the server uses QMail which has a bug that sends a copy of the mail for any TO field, so 2 copies get sent not 1.
Also note that there is a ; (semi-colon) at the end of each header, this also is needed otherwise the message gets sent as text. - This had me stumped for a while as my test server didn't need them!