Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail() issues "Return-Path: "

Status
Not open for further replies.

rrsub

MIS
Joined
Oct 23, 2002
Messages
536
Location
US
On a Win32 platform;

In my php.ini, I have set 'sendmail_from=me@domain.com;'

In my headers I have a proper 'Return-Path:' and 'From:' with the "\r\n" and other required header information that gets passed correctly.

I'm using mail($to,$subject,$message,$headers);

My problem is that the 'Return-Path:' in the client who recieves the email is set to what the php.ini is set to and not what the header is set to.

If I comment out the line in the php.ini, I get an error that says that I don't have a Return-Path: or a From: available in my header.

My Return path is 'Return-Path: me@domain.com\r\n'
My From is 'From: My Name<me@domain.com>\r\n'

The "From" is fine but what happens is that email address that is the 'To: ' has an autoresponder and automatically send a message to 'sendmail_from' and not 'Return-Path:'

 
What about sending a reply-to header? Have you tried that?
 
Yup.

$headers = "".
"Content-Type: text/html \r\n".
"Date: ".date("r")."\r\n".
"Return-Path: ".$return_path."\r\n".
"From: ".$hdr_from."\r\n".
"Sender: ".$hdr_from."\r\n".
"Reply-to: ".$hdr_from."\r\n".
"Organization: domain.net\r\n".
"X-Sender: ".$hdr_from."\r\n".
"X-Priority: 3 \r\n".
"X-Mailer: Domain-Mailer \r\n";

$hdr_from is chosen from the site owner.
$return_path is either the site owner or the form users email address.

I know the return path is supposed to be where the mail gets bounced to if the 'To: ' is invalid but the autoresponder sends the message to the 'Return-Path:'
 
Figured it out.

Not many responses on this question. Do you guys use the mail() function?

Anyway, here's my solution;

ini_set("sendmail_from",$return_path);

$headers = "".
"Content-Type: text/html \r\n".
"Date: ".date("r")."\r\n".
#"Return-Path: <".$return_path.">\r\n". // Might as well remove this
"From: ".$hdr_from."\r\n".
"Sender: ".$hdr_from."\r\n".
"Reply-to: ".$hdr_from."\r\n".
"Organization: domain.net\r\n".
"X-Sender: ".$hdr_from."\r\n".
"X-Priority: 3 \r\n".
"X-Mailer: Domain-Mailer \r\n";
 
rrsub said:
Do you guys user the mail() function?

I do, but generally only indirectly. If I have do send complex emails, I generally use the PHPMailer class.


Also, mail() on Win32 behaves differently from mail() on unix-like OSes. And different MTAs on unix-like OSes behave differently from one another in how they interact with PHP.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top