tags:

views:

149

answers:

3

Is there a way to change the return-path using PHPMailer

I did the following and it did not work

$mail->AddCustomHeader('Return-path:[email protected]');

I'm using the following statement to send mails

if(!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;

    } else {
        //Building the reporting email to report on all the mails send 
        echo "Message REPORT sent!\n";
    }

I get the email but the return path does not change?

A: 

The most probable reason for this is that the mail server you’re sending this mail over enforces a specific return path. This is often the case for “hosted” webspace.

In that case, you don’t have a lot of options. Try talking to your hoster.

Scytale
+1  A: 

Instead of using the Reply-path header, try this:

$mail->AddCustomHeader('Reply-to:[email protected]');

I use the Reply-to header and have had great success even on shared spaces.

webfac
Did I misunderstand you? Are you wanting to change the path to which failed messages and warnings are sent to or are you wanting to change the address whereby people REPLY TO?
webfac
@webfac, if the mail is not delivered the email bounces back, I need to know to which address it bounces to and the only thing I think it bounces to is the reply-path
Roland
@Roland - That's correct yes, I misunderstood you for a moment. I see no reason why the Reply-path is not working, UNLESS this header is being placed BEFORE your standard To, From headers etc ?? If so taht may very well be the answer.
webfac
@webfac, I've managed to solve this I did the following $mail->Sender = '[email protected]';
Roland
@Roland - Glad you sorted it out, that means that the class you're using has the function Sender in it which obviously applies the sender address to the From: AND Return-path header values. That's a strange way of doing it, I would prefer it if they gave you the option to implicitly set each header option yourself! Glad you nailed it though.
webfac
@webfac, I agree with you. At least we know now
Roland
+1  A: 

The following solved the issue, I adjusted the Sender property and it worked for me. $mail->Sender = '[email protected]';

Roland