akwok
akwok

Reputation:

PHP, set bounce back email address

When using PHP to send email, how can I set the return path for receiving bounced back emails?

Upvotes: 5

Views: 9854

Answers (2)

n1313
n1313

Reputation: 21381

There is a parameter in mail() that allows user to set additional headers. You should set a "Return-Path" header, like this:

mail($email, $subject, $message,
"From: $returnaddress\n"
. "Reply-To: $returnaddress\n"
. "Return-Path: $returnaddress");  

Upvotes: 4

John Chandler
John Chandler

Reputation: 829

To get this to work on my server (bluehost) I had to also use the fifth parameter (i.e. "$additional") as shown below:

     $headers = "From: [email protected]\r\nReply-To: [email protected]";

     $additional = "[email protected]";

     mail("[email protected]", "Subject", "Message",$headers, $additional); 

Upvotes: 4

Related Questions