Mike,

Here is how I send an HTML e-mail. Say I have a contact form with the values $name, 
$email, and $message. The form submits to.... say..... process.php.


<?
// process.php

$message = stripslashes(nl2br($message));
$date = Date("F d, Y h:i a");


$body = "
<p><font color='#990000' face='Arial, Helvetica, sans-serif'><strong>Contact Us 
Submitted $date</strong></font></p>
<table width='300' border='1' cellspacing='1' cellpadding='3'>
  <tr> 
    <td width='113'><font face='Arial, Helvetica, sans-serif'>Name:</font></td>
    <td width='187'><font face='Arial, Helvetica, sans-serif'>$name</font></td>
  </tr>
  <tr> 
    <td><font face='Arial, Helvetica, sans-serif'>E-mail address</font></td>
    <td><font face='Arial, Helvetica, sans-serif'>$email</font></td>
  </tr>
  <tr> 
    <td><font face='Arial, Helvetica, sans-serif'>&nbsp;</font></td>
    <td><font face='Arial, Helvetica, sans-serif'>&nbsp;</font></td>
  </tr>
  <tr> 
    <td><font face='Arial, Helvetica, sans-serif'>Message:</font></td>
    <td><font face='Arial, Helvetica, sans-serif'>$message</font></td>
  </tr>
</table>
";

$subject = "Contact Us submission from your website";
$to  = "John Doe <[EMAIL PROTECTED]>" . ", " ; //note the comma

/* To send HTML mail */
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* This sets the 'from' field to the Name and E-mail that was just submitted
$headers .= "From: ";
$headers .= $name;
$headers .= " <";
$headers .= $email;
$headers .= ">\r\n";

/* Send it!! */

mail($to, $subject, $body, $headers);

?>

That's it. The key part are the two header lines that set the MIME-Version, and the 
Content-type. Other than that it's the same.

Note... I changed all the double-quotes in the HTML code to single quotes. This way I 
could use double-quotes around the whole block of HTML, and simply insert the PHP 
variables where desired without have to chop apart the $body. (make sense?)

Hope this helps.

Joseph


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to