简体   繁体   English

PHP 清除“回复:”邮件

[英]PHP Clear "reply-to:" for mail

Example:例子:

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

My current code:我目前的代码:

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;
}

The problem i'm having is that email 1 has been sent successfully the reply-to: is test@testing.co.uk, then email 2 is sent and the reply-to: is both test@testing.co.uk and support@testing.co.uk .我遇到的问题是电子邮件 1 已成功发送, reply-to:是 test@testing.co.uk,然后发送电子邮件 2, reply-to:test@testing.co.uksupport@testing.co.uk

I want it to reset the reply-to: for each email sent so that it doesn't have the issue of having two reply-to: 's我希望它为每封发送的电子邮件重置reply-to: reply-to:

According to the documentation there is a method called clearReplyTos .根据文档,有一种方法叫做clearReplyTos You could try calling that first as below:您可以尝试先调用它,如下所示:

$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);

I haven't used it myself but just a quick skim of the doc pages brought that up.我自己没有使用过它,但只是快速浏览了文档页面就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM