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("email@example.com", "subject", "body of message", "From: firstname.lastname@example.org", "-email@example.com");
The part of the code that does this is "-firstname.lastname@example.org".
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.
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.