views:

37

answers:

2

Hi there,

I got a strange problem with php mail and exchange. When I use the a simple php html mailscript, see below (can be found all over internet) I see the mail as kind of plain text (see below) mail in Microsoft Exchange. But when I send the mail to an other account with Outlook I see the mail as a HTML-mail as it should be.

Doest anybody got a clue?

Mailscript:

<?php
// multiple recipients
$to  = '[email protected]' . ', '; // note the comma
$to .= '[email protected]';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

View in Exchange:

Content-type: text/html; charset=iso-8859-1

From: Birthday Reminder <[email protected]>
Subject:Birthday Reminders for August

Return-Path: [email protected]
X-OriginalArrivalTime: 06 Oct 2010 13:39:59.0117 (UTC) FILETIME=[F839FBD0:01CB655B]

<html>
    <head>
      <title>Birthday Reminders for August</title>
    </head>
    <body>
      <p>Here are the birthdays upcoming in August!</p>
      <table>
        <tr>
          <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
        </tr>
        <tr>
          <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
        </tr>
        <tr>
          <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
        </tr>
      </table>
    </body>
    </html>
A: 

Have you tried using Content-Type instead of Content-type? (capitalize the type)

amphetamachine
Ok, will try it when I get home.But strange thing is that it worked for 1.5 years,and yesterday it gave problems
Megapool020
A: 

try replace the "\r\n" to "\n" in the headers

Haim Evgi
Ok, will try it when I get home.But strange thing is that it worked for 1.5 years,and yesterday it gave problems
Megapool020
what is the type of the machine that send the mail ?
Haim Evgi
It's a webserver that is hosted in the Netherlands
Megapool020
what i mean it is unix, linux ? windows ? , some unix machines do problem with \r\n
Haim Evgi