PHP Clear "reply-to:" for mail


PHP Clear "reply-to:" for mail

示例:

email 1 has email to reply to as `test@testing.co.uk`
email 2 has email to reply to as `support@testing.co.uk`

我的当前代码:

if($this->teacherEmail && $this->teacher_reply_enable)
    $this->mail->AddReplyTo($this->teacherEmail, $this->schoolTitle);
else 
    $this->mail->AddReplyTo($this->schoolEmail, $this->schoolTitle);
$this->mail->Subject = $this->subject;
$this->mail->msgHTML($this->getMessage());
$this->mail->AltBody = strip_tags($this->message);
$this->mail->addAddress($this->to, $this->to_name);         
foreach($this->attachments as $item){   
    $email_attachment = DOC_ROOT.$item->path.$item->orig;
    $email_attachment_title = $item->name;
    $this->mail->addAttachment($email_attachment,$email_attachment_title);
}
if (!$this->mail->send()) {
    return false;
} else {
    return true;
}

我遇到的问题是电子邮件1已经成功发送,reply-to:是test@testing.co.uk,然后电子邮件2被发送,reply-to:test@testing.co.uksupport@testing.co.uk

我希望它重置reply-to:为每发送的电子邮件,这样它就不会有两个reply-to:的问题

根据文档,有一个叫做clearReplyTos的方法。您可以尝试先调用它,如下所示:

$this->mail->clearReplyTos();
if($this->teacherEmail && $this->teacher_reply_enable)
    $this->mail->AddReplyTo($this->teacherEmail, $this->schoolTitle);
else 
    $this->mail->AddReplyTo($this->schoolEmail, $this->schoolTitle);

我自己没有使用过,但是我只是快速浏览了一下文档页面,就想到了