Click to See Complete Forum and Search --> : Trying to send html mail via PHP


Perfidus
12-15-2003, 11:36 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:




<?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&uacute;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);
}
?>

olaf
12-15-2003, 01:55 PM
Hallo,

the echo in the message is to much...

pyro
12-15-2003, 08:11 PM
I'm assuming what you meant to say was the echo in the message is not needed?

/* 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&uacute;mero

de referencia:</strong> ".$codigo."<img src='http://www.whatever.com/images/1nada.gif' width='10' height='9'></font></div></td>
</tr>
</table>
</body>
</html>
"; And actually, with PHP's variable interpolation, you wouldn't even need the ". and ." before and after it, since you are using double quotes for the string.