This is interesting: in testing this on the server in question, the "-f" does 
nothing (with a lowercase -f).

In an older sendmail man page I just came across it says "... -f can only be 
used by trusted users (normally root, daemon, and network) or if the person you 
are trying to become is the same as the person you are."
So I guess my php code doesn't get permission to use it. (The current man page 
doesn't have that ...)

"-r" sets the Return-Path and the From if there is no From in the $headers set 
in the php code, otherwise the -r sets only the Return-Path.


So what works for my setup is:

$headers = 'Reply-To: ri <[email protected] >' . PHP_EOL . 'From: ri 
<[email protected] >'  ;
$subject ="some subject";
$message = 'some text';
$to = "some one <[email protected]>";

$done = mail($to, $subject, $message, $headers, '-r [email protected]');


The message then arrives with the different addresses as expected:

Return-Path: <[email protected]>
To: some one <[email protected]>
Subject: some subject
Reply-To: ri <[email protected]>
From: ri <[email protected]>



And it does go via Postfix, from the Log:

Dec 12 18:24:34 machine-domain postfix/qmgr[2578]: CF99E10119: 
from=<[email protected]>, size=427, nrcpt=1 (queue active)
Dec 12 18:24:36 machine-domain postfix/smtp[12071]: CF99E10119: 
to=<[email protected]>, ...




On 12 déc. 2010, at 18:20, Wietse Venema wrote:

> R.A. Imhoff:
>> In fact what finally does set the Return-path is to use the "-r" parameter 
>> in the 5th place:
>> 
>>    $result = mail($to, $subject, $message, $headers, "-r [email protected]")
>> 
>> the "-f" sets the "From:", but that was already working by setting it in the 
>> $headers or in the php.ini
> 
> No, that is incorrect.
> 
> With POSTFIX, the -f and -r options do exactly the same thing:
> 
>        case 'f':
>            sender = optarg;
>            break;
>       ...
>        case 'r':                               /* obsoleted by -f */
>            sender = optarg;
>            break;
> 
> If you look in your logging, you may find that you are handing the
> mail to something other than POSTFIX.
> 
> POSTFIX submissions looks like:
> 
> pickup[xx]: yyy: uid=1001 from=<wietse>
> cleanup[zz] yyy: message-id=<[email protected]>
> 
>       Wietse

Reply via email to