Papa De Beau
Papa De Beau

Reputation: 3828

PHP Mailer --- Reply-to: --- Return-path --- SetFrom

I am sending mail via PHP Mailer. http://phpmailer.worxware.com/

I want to be able to set the From to one emailand the REPLY-TO to another email and the RETURN-PATH to yet another.

Mainly.. I want the bounced emails to go to something like BOUNCEDemails@bademail.com I was hoping the RETURN PATH could do this.

And if a user who gets the email I don't want them to see its from BOUNCEDemails etc.. to I want to give them an option to reply to a real email address.

I need the bounced emails tho to go to a seperate email because I don't want the REPLY TO to get many bad emails. etc..

HERE IS WHAT I HAVE: Does Not work

$mail->AddAddress('ed@RealEmail.org', 'John Doe');
$mail->AddReplyTo('replytoMe@email.com', 'Reply to email');
$mail->SetFrom('mailbox@email.com', 'From Name and Email');
$mail->AddCustomHeader('Return-path: BOUNCEDemails@bademail.com');

The code above replies to SetFrom and sends all bounces to SetFrom. Any ideas how to separate the two? Thanks

Upvotes: 3

Views: 12457

Answers (3)

Magor Menessy
Magor Menessy

Reputation: 423

$mail->AddReplyTo('replytoMe@email.com', 'Reply to email');
$mail->AddAddress('ed@RealEmail.org', 'John Doe');

Notice the order! AddReplyTo has to be BEFORE AddAddress!!!

Upvotes: 1

Milos Cuculovic
Milos Cuculovic

Reputation: 20223

You may use

$mail->AddReplyTo('name@yourdomain.com', 'First Last');

Upvotes: 2

anonymous-one
anonymous-one

Reputation: 15112

the correct way to set this (as of july 2013) is by using:

$mail->ReturnPath='bounce_here@domain.com';

the phpmailer source contains the following, which is fairly self explanatory:

if ($this->ReturnPath) {
  $result .= $this->HeaderLine('Return-Path', '<'.trim($this->ReturnPath).'>');
} elseif ($this->Sender == '') {
  $result .= $this->HeaderLine('Return-Path', '<'.trim($this->From).'>');
} else {
  $result .= $this->HeaderLine('Return-Path', '<'.trim($this->Sender).'>');
}

Upvotes: 4

Related Questions