PDA

View Full Version : html emails


Nightfire
12-24-2002, 08:19 PM
Ok, this is really baffling me. I'm trying to send an html email off, but all I'm getting is the html shown in the email. This is what's baffling me... The script below works with html

<?php
$to="your@email.com";
$subject="My Test Email";
$body="<html><body><h1>My Test Email Works!</h1></body></html>";
$headers = "MIME-Version: 1.0";
$headers .= "Content-type: text/html; charset=iso-8859-1";
$headers .= "From: My Name <myscript@mydomain.com>";
mail("$to","$subject","$body","$headers");
?>

But if I try to change $body to include

<html><body><h3>Merry Christmas</h3>Have a great Christmas and New Year from everyone at etc etc, you get the idea</body></html>

I just get it all printed in the email :confused: I've stripped most the html out too, thinking that emails couldn't contain stylesheets, title tags, etc

sir pannels
12-26-2002, 02:47 AM
you tried printin the headers befor the body?

firepages
12-26-2002, 03:39 AM
Hi, that code worked for me, but you should really be putting newlines after the headers..

$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";

+ you dont need to use the quotes here if you are passing a variable (not that it should relly hurt ?)

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

Nightfire
12-26-2002, 05:30 AM
Ta, I tried all sorts of ways, including the way shown, but it didn't seem to work :confused: It doesn't matter anymore now, the client doesn't want html emails being sent :)