I have an SMTP question. I have created a PHP script to send out emails. The requirement is that I need to send email from '[email protected]' but I need replies to come to '[email protected]'
I have added [email protected]
in the reply-to
header field. The only problem I am having is that when someone receives the email and clicks on the reply button, both [email protected]
and [email protected]
are being shown in the TO
field.
Is there any way that I can have [email protected]
removed from the TO field and only show the email address that was specified in the reply-to
field?
I am using PHPMailer and the code is below:
$this->phpmailer->IsSMTP();
$this->phpmailer->Host = $server;
$this->phpmailer->Port = $port;
$this->phpmailer->SetFrom($fromEmail, $fromName); //this is [email protected]
$this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is [email protected]
$this->phpmailer->Subject = $subject;
$this->phpmailer->AltBody = $msgTXT; // non-html text
$this->phpmailer->MsgHTML($msgHTML); // html body-text
$this->phpmailer->AddAddress($email);
Try:
$this->phpmailer->IsSMTP();
$this->phpmailer->Host = $server;
$this->phpmailer->Port = $port;
$this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is [email protected]
$this->phpmailer->SetFrom($fromEmail, $fromName); //this is [email protected]
$this->phpmailer->Subject = $subject;
$this->phpmailer->MsgHTML($msgHTML); // html body-text
$this->phpmailer->AddAddress($email);
Try setting AddReplyTo() first before SetFrom. phpmailer needs to change this behavior. It adds the from address to the reply-to field. If you set reply-to first before the from address, it will not be able to add your from address to the reply-to header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With