Trying to send html mail via PHP
Posted: Mon Dec 15, 2003 11:38 am
I have this code whit which I'm trying to send an emial formated with HTML, the problem is that inside the HTML there are some PHP tags embeded and I think that's the reason it doesn't work even though maybe there 1 or 2 thousand reasons more:
Code: Select all
<?php
/* recipients */
$to = "whatever@whatever.com" . ", " ; // note the comma
$to .= "whatever@whatever.com";
/* message */
$message = "
<body>
<html>
<table width='100%' border='1' cellpadding='0' cellspacing='0' bordercolor='#CCCCCC'>
<tr>
<td><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>
<tr>
<td colspan='2'><div align='right'><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Número
de referencia:</strong> ".echo $codigo."<img src='http://www.whatever.com/images/1nada.gif' width='10' height='9'></font></div></td>
</tr>
</table>
</body>
</html>
";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers .= "To: whatever <whatever@whatever.com>, whatever <whatever@whatever.com>\r\n";
$headers .= "From: Customer <$email>\r\n";
/* and now mail it */
mail($to, $subject, $message, $headers);
}
?>