Jump to content


Photo

php html mail


  • Please log in to reply
3 replies to this topic

#1 kratak

kratak
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 18 July 2006 - 04:53 PM

Hi

Im trying to use a script to send a html email to various people. If i send it to a hotmail user and open the email, the email does appear correct, processing the html code. However if you access the same email via Outlook (2003) it comes out showing the code rather than interpreting it.

Ive tried several websites and the they all talk about the headers. I have tried several different bits of code in the headers, all have had no effect. Any advice welcome.

Here is my code

<?php 


$email = array('email@hotmail.com', 'email2@hotmail.com');

foreach ($email as $k => $v) {

	$to = $v;
	$from = "research@roffeypark.com";
	$subject = "subject";

$headers = "From: info@mydomain.com\n"; 
$headers .= "Message-ID: <" . md5(uniqid(time())) . "@mydomain.com>\n"; 
$headers .= "MIME-Version: 1.0\n"; 
$headers .= "Date: ".date("D, d M Y H:i:s") . " UT\n"; 
$headers .= "Reply-To: info@mydomain.com\n"; 
$headers .= "Return-Path: info@mydomain.com\n"; 
$headers .= "X-Priority: 3\r\nX-MSmail-Priority: Normal\n"; 
$headers .= "X-mailer: php/".phpversion()."\n"; 
$headers .= "X-MimeOLE: Produced By MyDomain\n"; 
$headers .= "Content-type: text/plain; charset=iso-8859-1\n"; 
 

$message = "
<html>
<body>
<p><font color='red'>Hello</font></p>
</body>
</html>";
	
mail($to, $subject, $message,$headers);

	
	
}

?>


#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 18 July 2006 - 04:58 PM

I think the problem is here:
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";

Instead of text/plain it should be something else (I dont know what, my guess will be "text/html" or something like that).

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 willfitch

willfitch
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts
  • LocationNew Hope, PA

Posted 18 July 2006 - 05:00 PM

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
Zend Certified Engineer (ZEND001989)
www.willfitch.com

#4 kratak

kratak
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 18 July 2006 - 05:14 PM

thanks, that solved it





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users