在电子邮件中设置replyTo字段

Und*_*ble 4 php email

我有一个SMTP问题.我创建了一个PHP脚本来发送电子邮件.要求是我需要从'email1@example.com'发送电子邮件,但我需要回复'email2@example.com'

email2@example.comreply-to标题字段中添加了.我遇到的唯一问题是,当有人收到电子邮件和点击回复按钮,既email1@example.comemail2@example.com被显示在TO现场.

有什么方法可以email1@example.com从TO字段中删除,只显示字段中指定的电子邮件地址reply-to

我使用的是PHPMailer,代码如下:

    $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);
Run Code Online (Sandbox Code Playgroud)

rat*_*oss 8

尝试:

$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);
Run Code Online (Sandbox Code Playgroud)

尝试在SetFrom之前先设置AddReplyTo().phpmailer需要改变这种行为.它将from地址添加到reply-to字段.如果您在发件人地址之前设置了第一个回复,则无法将您的发件人地址添加到回复标头中.