1

I have a php app that sends email to the users. For most users this is just fine.

However users with Lotus Notes for their email client are recieving an email that appears to start with some of the headers I have added to the message.

I have tried changing the line endings, to no avail.

Here is the code that sends the emails. (in a loop - $row is from the database).

    $to = $row['email'];
    $subject = $language['summary'];
    $headers = "From: $from\n".
        "Reply-To: $from"."\n" ;
    if (!mail($to, $subject, $body,$headers,"-f$from")) {
        echo("<p>Message delivery failed to $to</p>");
    }

Lotus Notes treats X-Mailer:PHP/5.3.2-1ubuntu4.7 as the first line of the content!

Has anyone any idea why, and how I can change the email to work correctly?

Edit - 1 Aug - Tried \r\n and PHP_EOL as line endings. Nothing works with notes. Everythgin workes wiith every other tested MTA.

Ian
  • 1,941
  • 2
  • 20
  • 35
  • Do you have an example of the raw mail that is actually sent? Check that you don't have an extra new line before the X-Mailer header. – Kerr Jul 19 '11 at 20:41
  • Not yet - however the system has been working for a while with no complaints except from Notes users. Without a detailsed check that will inclide Thunderbird, MS's mail client and Google for sure, so there can't be much wrong. I have corrected the inconsistent line breaks, and that has not solved the proble. – Ian Jul 28 '11 at 18:19
  • How can I find the raw mail actually sent? I have copied myself in and the mail I recieved is 100% normal in every respect. All lines end with CRLF, and there are no unexpected blank lines anywhere. – Ian Aug 01 '11 at 16:11
  • Most mail programs have an option for view "raw message" or "original message" or something like that. You should just see a big chunk of text with the headers at the top, then a single blank line then the body. You might also see a bunch of MIME stuff in there as well. – Kerr Aug 03 '11 at 01:02

1 Answers1

0

You are using inconsistent line breaks for your headers. Use \r\n for both:

$headers = "From: $from\n".
    "Reply-To: $from"."\r\n" ;

// Should be
$headers = "From: $from\r\n".
    "Reply-To: $from\r\n" ;

Depending on the MTA handling the SMTP transaction, failing above it may work better for you to use the PHP_EOL constant for line breaks:

$headers = "From: $from" . PHP_EOL .
    "Reply-To: $from" . PHP_EOL ;
Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
  • I know the line endings are inconsistent. This was the latest version, and tried after much Googling. I have arranged a test (may take a day or two - I don't have Notes). – Ian Jul 17 '11 at 21:34
  • Make that a week - the guy who needs to test is on holiday! – Ian Jul 23 '11 at 08:17