Setting the replyTo field in an email message

I have a SMTP question. I created a PHP script to send emails. The requirement is that I need to send an email with " email1@example.com ", but I need answers to go to " email2@example.com "

I added email2@example.com in the reply-to header field. The only problem that I encountered is that when someone receives an email and presses the reply button, the tags email1@example.com and email2@example.com displayed in << 24>.

Is there a way to remove email1@example.com from the TO field and show only the email address specified in the reply-to field?

I am using PHPMailer, and the code below:

  $this->phpmailer->IsSMTP(); $this->phpmailer->Host = $server; $this->phpmailer->Port = $port; $this->phpmailer->SetFrom($fromEmail, $fromName); //this is email1@example.com $this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is email2@example.com $this->phpmailer->Subject = $subject; $this->phpmailer->AltBody = $msgTXT; // non-html text $this->phpmailer->MsgHTML($msgHTML); // html body-text $this->phpmailer->AddAddress($email); 
+4
source share
2 answers

Try:

 $this->phpmailer->IsSMTP(); $this->phpmailer->Host = $server; $this->phpmailer->Port = $port; $this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is email2@example.com $this->phpmailer->SetFrom($fromEmail, $fromName); //this is email1@example.com $this->phpmailer->Subject = $subject; $this->phpmailer->MsgHTML($msgHTML); // html body-text $this->phpmailer->AddAddress($email); 

Try setting AddReplyTo () before SetFrom. phpmailer should change this behavior. It adds the address from the address to the response field. If you set the response first to the from address, it cannot add your address to the response header.

+8
source

From google search and first result

Adding a Reply Address ^

By default, the Reply-to address will be the FROM address unless you specify otherwise. It is just intelligence for email. However, you can receive e-mail from one email address, and any responses go to another. Here's how:

$mailer->AddReplyTo(' billing@yourdomain.com ', 'Billing Department');

Note: You can have multiple Reply-To addresses, just duplicate the line in the previous code example and change the E-Mail address on each line.

You will need to add this line to your address. P rent this solution to solve the same problem.

Following these examples, your code should look like

 $this->phpmailer->IsSMTP(); $this->phpmailer->Host = $server; $this->phpmailer->Port = $port; $this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is email2@example.com $this->phpmailer->SetFrom($fromEmail, $fromName); //this is email1@example.com $this->phpmailer->Subject = $subject; $this->phpmailer->AltBody = $msgTXT; // non-html text $this->phpmailer->MsgHTML($msgHTML); // html body-text $this->phpmailer->AddAddress($email); 
0
source

All Articles