Phpmailer and return-path

How do I set the return path using phpmailer?


Try using the following (corrected for your use with a phpmailer object named mail):

	$mail->From = "";
	$mail->FromName = "Your Name";
	$mail->AddReplyTo("", "My Myself & I");



Hi DK,

Thanks but that didn’t do the trick.
If the e-mail goes through, the AddReplyTo allows me to set where I want the reply to go but I’m looking to get responses for the e-mails that bounce.

When I look at the headers in my e-mail it shows
Return-Path: <>

I’d like it to be
Return-Path: <>

I’ve also tried extending the class as below but that hasn’t worked either
class MyMailer extends PHPMailer {
// Set default variables for all new objects
var $From = “”;
var $FromName = “TriDuo”;
var $Sender = “”;

Any other solutions?

If you’re referring to this:
then it should be defined with the $sender var, not?

so just edit line 74 of the class.phpmailer.php file.

Makes sense to me… but no guarantees :slight_smile:


ColinF has suggested changing the DEFAULT From setting in the class.phpmailer.php file. That would still be overwritten by the assignments ( $mail->From = “”; and $mail->FromName = “TriDuo”; ) to the class variables.

From the look of your errors, though, it seems as if your SMTP setup in Apache is what’s being sent instead (<>). If this is on your own server, you can change this in the Apache configuration. If it’s on a shared server, your host will likely not allow this to be changed but should be able to tell you how to get around this.

I would expected $mail->From to have overridden the Apache’s From setting for you so I have to ask if you’ve tried these statements in your script (before attacking Apache’s config file).



I’m having similar trouble. The weird thing is, that everything works except AddReplyTo!

So, for example:


all work fine. But this one:


doesn’t seem to override the default Emails go through okay, but when they do bounce the go back to my host.

Anyone else had this trouble? Why would one line fail and all the other work okay???

Just to know, which phpmailer are you talking about ?
from xoops, sf, or the similar ?
edited, inherited ? you really affray me.
Quick test, quick modified and back and again and forth.

Could it be the last stage (SMTP) building the end message ?

You want Return-Path different from ReplyTo or do I miss the subject ?

I’m talking about this one:

you really affray me.
Quick test, quick modified and back and again and forth.

Sorry - I’m not sure what all that means… :blush:

But I haven’t edited the class.phpmailer.php file if that’s what you’re asking.

I don’t necessarily want it to be different, I just want it to be there. If I don’t specify anything, it’s the standard server address above. If I do specify an address using AddReplyTo() it makes no difference.

I haven’t specified it should use SMTP, and I haven’t even uploaded class.smtp.php… So if it were an SMTP issue the mail would probably not even send in the first place. I think.

this is a very old thread!.. sorry to reply to an old thread… just thought this will be useful to some one else…

to set the return path in phpmailer you have to use


Ok. But what if I need to the return-path to be diferent from the Reply-to address??