PHP Classes
elePHPant
Icontem

Can we set a return path for bounced emails?

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      SMTP E-mail sending class  >  All threads  >  Can we set a return path for bounced...  >  (Un) Subscribe thread alerts  
Subject:Can we set a return path for bounced...
Summary:Can we set a return path for bounced emails?
Messages:3
Author:Roy Martins
Date:2013-05-13 20:22:13
Update:2013-05-14 04:44:07
 

  1. Can we set a return path for bounced...   Reply   Report abuse  
Picture of Roy Martins Roy Martins - 2013-05-13 20:22:13
I'm attempting to have bounced emails go to another email address, however, they are being sent to the email being sent from. This is what I've done (at the bottom of test_smtp.php:

array(
"From: Myreturnemailaddress",
"Reply-To: Myreturnemailaddress",
"Return-Path: Myreturnemailaddress",
"To: $to",
"Subject: TEST",
"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
),

Bounced messages are still being sent to the original SMTP provider email address that I've sent the email from. Can you suggest how I can change this? This can be done (and works) with the traditional PHP Mail Function:

mail("to@example.com", "subject", "body of message", "From: sender@example.com", "-fsender@example.com");

The part of the code that does this is "-fsender@example.com".

Any help would be appreciated.

  2. Re: Can we set a return path for bounced...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-05-14 04:44:07 - In reply to message 1 from Roy Martins
The Return-Path header is irrelevant. It is set by the SMTP server, not by the SMTP client sending the message.

You should use the MIME message class instead in conjunction with the SMTP to set the protocol information correctly using the Return-Path. It does the necessary emulation to make the messages bounce to the address you specify with that header.

phpclasses.org/mimemessage

  3. Re: Can we set a return path for bounced...   Reply   Report abuse  
Picture of Rene Rene - 2015-03-01 17:51:33 - In reply to message 2 from Manuel Lemos
This question is a little bit old, but maybe someone like me looking for a solution.
Just set the $from address in the SendMessage method to your bounce address and in the header array you set the real from address.
The address in the $from variable is set as MAIL TO address in the envelope which is used by the smtp server as return-path.
Example:

$smtp->SendMessage(
'bounce@your-email-address.com',
array(
$to
),
array(
"From: the_real_sender@your-email-address.com",
"To: $to",
"Subject: Testing Manuel Lemos' SMTP class",
"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
)