Page 1 of 1
sending mail with html
Posted: Thu Nov 03, 2005 10:35 pm
by pinehead18
When i use the basic mail function mail(to, sub, body)
with </b>hi</b> in it it sends the actual </b> and doen'st make the hi bold..
Any ideas?
thank you
Anthony
Posted: Thu Nov 03, 2005 10:47 pm
by John Cartwright
Google is your friend
http://www.zend.com/zend/trick/html-email.php
Code: Select all
<?php
//add From: header
$headers = "From: webserver@localhost\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
//unique boundary
$boundary = uniqid("HTMLDEMO");
//tell e-mail client this e-mail contains//alternate versions
$headers .= "Content-Type: multipart/alternative" .
"; boundary = $boundary\r\n\r\n";
//message to people with clients who don't
//understand MIME
$headers .= "This is a MIME encoded message.\r\n\r\n";
//plain text version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/plain; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("This is the plain text version!"));
//HTML
version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("This the <b>HTML</b> version!"));
//send
message
mail("root@localhost", "An HTML Message", "", $headers);
?>
Posted: Thu Nov 03, 2005 11:06 pm
by pinehead18
Code: Select all
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($mailto, "ORDER INFORMATION", $mail_body, $headers);
}
Wont work:(
Posted: Thu Nov 03, 2005 11:33 pm
by pinehead18
Got it, thank you for your help