Not sure what is wrong, I made sure to set my headers so perhaps something is wrong. The mailscript that I have is huge so I put together this little tester, when i receive the emails all the html tags are present but no formatting took place. I’m curious if it’s a problem with the way I set up the header or if I needed more to it. I searched the forums and it looked like the problem most people had was they weren’t adding in the HTML content-type but that is added in here, so any help would be awesome.
thanks
Okay so I’ve checked out some tutorials online
http://www.webhostingtalk.com/showthread.php?t=416467
http://css-tricks.com/2866-sending-nice-html-email-with-php
http://www.w3schools.com/php/func_mail_mail.asp
<?php
session_start();
if (isset($_SESSION['new_count'])) //counts how many fake emails i send myself
{
$count = $_SESSION['new_count'];
}
else
{
//first time
$count = 0;
}
$to = 'myemail@gmail.com';
$subject = 'email test';
$message = '<html><head></head><body>';
$message .= '<h1>this is an email test</h1>';
$message .= '<br />does new line work?<br />';
$message .= 'how about <b>bold</b> and <strong>strong</strong>?<br />';
$message .= '</body></html>';
//updated my header to include mime-version
$mailheader = 'MIME-Version: 1.0' . '\r\n';
$mailheader .= 'Content-type: text/html; charset=ISO-8859-1' . '\r\n';
$mailheader .= 'from: abc@def.com <btyazaki@gmail.com>' . '\r\n';
$yay = mail($to,$subject,$message,$mailheader);
if($yay)
{
echo 'woot';
$count++;
$_SESSION['new_count'] = $count;
echo '<br>Emails Sent: '.$count;
}
else
{
echo 'no woot';
}
?>
I updated the headers to the suggested forms on W3 and a few other places. I’m guessing that my headers are the problem… this still outputs regular text not html not sure what the problem is. As for the structure of this script it’s not my actual mailer script it’s a test script w/ a counter so I know how many emails to look out for during a test session.
Try using double quotes for your \r\n.