Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I run Ubuntu 10.04 and installed a LAMP stack with a "satellite" Postfix (used as a relay for my ISP's smtp).

In php.ini, I kept the sendmail pass to default so with -t -i arguments:

;sendmail_path =

I send emails like this:

$headers  = 'From:' . "\r\n";
$headers .= 'Reply-To:' . "\r\n";
$headers .= 'Return-Path:';

mail('', 'Email title', 'Text of the body.', $headers);

The emails recieved have this in the body (It should be in the header):

Message-Id: <>
Date: Thu, 27 Oct 2011 23:02:18 +0200 (CEST)

How can we fix that?

Note: The emails are working properly on other installs: Gentoo with qmail or Windows with smtp set to my isp's in the php.ini.

Here is the full header:

Return-Path: <>
Received: (qmail 28922 invoked from network); 27 Oct 2011 23:00:55 +0200
Received: from (
  by with SMTP; 27 Oct 2011 23:00:55 +0200
Return-Path: <>
X-FXIT-IP: IPv4[] Epoch[1319888334]
Received: from [] ([]
    by (envelope-from <>)
    (ecelerity r()) with ESMTP
    id 6E/C0-28209-6D6C9AE4; Thu, 27 Oct 2011 21:02:14 +0000
Received: by (Postfix, from userid 33)
    id 6F32440DE7; Thu, 27 Oct 2011 23:02:18 +0200 (CEST)
Subject: Email Title
X-PHP-Originating-Script: 1000:helpdesk.php
share|improve this question
And what is in the header? – mailq Oct 27 '11 at 21:30
Voila. I modified the ips and the domains for privacy matters. Thanks. – Toto Oct 27 '11 at 21:36
up vote 3 down vote accepted

Postfix translates "line feed" (\n) into "carriage-return line-feed" (\r\n). Try removing the \r and using just \n.

share|improve this answer
This is crazy. I cannot believe it was this... "If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822" – Toto Oct 27 '11 at 22:02
Do you know if there is a way to handle correctly the "carriage-return line-feed" with Postfix (2.7.0)? – Toto Oct 27 '11 at 22:11
No, sorry. Postfix 2.9 has a new sendmail_fix_line_endings option which looks related – smin Oct 27 '11 at 22:33
Excellent link/info. Thanks. Postfix does not look like the ideal tool for my needs, so I finally installed Sendmail following the instructions on this page: – Toto Oct 27 '11 at 23:08

Your statements and the header don't match. Probably just a copy&paste error but is a bad starting point for diagnosis.

Then you have two Return-Path lines in the header and one in the body. THAT is strange and an indication for a bigger problem.

The overall problem is that you are trying to identify a problem with a header of a mail that went through four(!) email servers. And you then blame one of them as the culprit. But it can be any of them. Or most obvious none of the five as mail servers in general don't modify headers or bodies, except they are told to or required by RFC 5321. So if you want to analyze the problem you have to look how the mail arrives at the first server and not at the upcoming servers.

share|improve this answer
I find the first Return-Path: <> strange. It is the apache user. It overrides the specified one in the php code. – Toto Oct 27 '11 at 21:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.