mail () HTML question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

mail () HTML question

Post by rxsid »

Hi all,

I'm having trouble with the mail function. When the mail is sent from my web mail server, to MS outlook...it looks formated correctly, the HTML works as coded, etc. But when I try to retrieve it using my web based email application by HORDE, the HTML doesn't parse properly. I know the problem reside in this mail() function, because when I send an email from my desktop MS Outlook to the web based email, I can open the email and the HTML is just fine (i.e. a double return, translates to an empty space in between sentences), but if the same is sent from my php mail server, instead of a blank line in between, I get <BR> written litterly.
Heres what I have:

Code: Select all

//$headers .= "MIME-Version: 1.0\r\n";
   $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
   $headers .= "From: Somebody<webmaster@somesite.com>\n";
   $headers .= "Reply-To: <webmaster@somesite.com>\n";
   $headers .= "X-Sender: <webmaster@somesite.com>\n";
   $headers .= "X-Mailer: PHP4\n"; //mailer
   $headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal

   $subject = "Test Message!";

   $message = "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n";
   $message .= "<HTML><BODY>\n";
   $message .= "<center><a href="http://www.somesite.com"><img src="http://somesite.com/someimg.jpg" width="115" height="27" border="0"></a></center><br>";
  $message .="Some text here<br>";
  $message .="Some more text here.";
  $message .= "</body></html>";

   $email = "somebody@somesite.com";
   mail($email, $subject, $message, $headers);
If have tried sending with AND without the $message lines with <HTML> and <DOCYTYPE>
I have also tried with and without $headers MIME-version and without the \r in the Content-Type line.

None of these parse the HTML correctly on the web based email program if sent from my php mail server.

Any ideas?

Thanks.
Post Reply