Reputation: 279
The following headers are sent using PHP's mail() function:
$emailheaders = "From: " . $sender . "\n";
$emailheaders .= "Return-Path: " . $sender . "\n";
$emailheaders .= "MIME-Version: 1.0\n";
$emailheaders .= "Content-type: text/html; charset=UTF-8\r\n";
mail($email, $subject, $body, $emailheaders);
It works fine, except Return-Path:
is reset to [email protected]
, or at least this is what shows up when viewing extended headers for emails received using the above headers. Naturally this means that bounce emails are not received.
Does Apache reset the headers, and in this case why, or am I using mail()
incorrectly?
What can I do to prevent this from happening. Using mail()
's fifth parameter (e.g. -f [email protected]
) is out of the question as PHP is in safe mode and the provider will not change that. I suppose that there isn't some way to allow the fifth parameter for certain users despite safe mode being on.
The server is running Apache 2.2.3 and PHP version 5.1.6.
Upvotes: 1
Views: 2345
Reputation: 64526
The server's Mail Transfer Agent (MTA) is overriding the return-path
. For example if using Exim:
Set the return-path
in the /etc/exim/exim.conf
configuration file:
return_path = [email protected]
If you don't have access to the server config or the mail()
fifth parameter then there's probably nothing you can do.
Upvotes: 2
Reputation: 14173
You are splitting the headers using \n
but according to PHP it should be \r\n (see Which line break in php mail header, \r\n or \n?).
Perhaps thats the reason why the header isnt send correctly.
Upvotes: 0