PDA

View Full Version : HTML in Email


Sneath
March 27th, 2006, 14:17
I can't seem to sort out why my Emails wont be sent in HTML,
everything works fine, yet the Bold tags are actually displaying in the email rather than changing the font to bold.

Is there anything special I need to do?

$emailtext = "
Hello,

Your Details are as follows:
<b>Username:</b> ".$username."
<b>Password:</b> ".$password."
";

:banana2:

Odd Fact
March 27th, 2006, 18:52
What does the header information look like? Is html/text specified?

Sneath
March 27th, 2006, 19:34
<head>
<title>Clan Tactics Admin - Register User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

:roll:

It's not a major important thing, though i'd like to be able to include images etc..

jos
March 28th, 2006, 08:46
wait, everything works except the bold tags? or is the bold tags the only html in your email?

Sneath
March 28th, 2006, 18:03
yes, the bold tags are the only HTML

Anoop
March 29th, 2006, 09:29
Try setting the content type in the email headers. Here is an exaple :


$to = $email_id;
$subject = "Test mail";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $from\r\n";
$emailtext = "
Hello,

Your Details are as follows:
<b>Username:</b> ".$username."
<b>Password:</b> ".$password."
";
mail($to, $subject, $emailtext , $headers);

Sneath
March 29th, 2006, 10:34
Anoop,

I gave that a go and the email wouldn't send, I'm really not sure what else we could try lol :nod:

Anoop
March 29th, 2006, 10:59
Any error / warning anything?

change the last line to :

$status = mail($to, $subject, $emailtext , $headers);

if ($status ) {
echo "Mail was sent successfully ";
} else {
echo "Error sending mail";
}

Check whether all arguments of mail function is set.