Php 在电子邮件中设置replyTo字段
我有个问题。我已经创建了一个PHP脚本来发送电子邮件。要求是我需要发送电子邮件从'email1@example.com“但我需要回复”email2@example.com" 我添加了Php 在电子邮件中设置replyTo字段,php,email,Php,Email,我有个问题。我已经创建了一个PHP脚本来发送电子邮件。要求是我需要发送电子邮件从'email1@example.com“但我需要回复”email2@example.com" 我添加了email2@example.com在回复标题字段中。我唯一的问题是,当有人收到电子邮件并点击回复按钮时,两者都email1@example.com和email2@example.com显示在至字段中 我有什么办法可以使用email1@example.com从“收件人”字段中删除,只显示在“回复”字段中指定的电子邮件
email2@example.com
在回复
标题字段中。我唯一的问题是,当有人收到电子邮件并点击回复按钮时,两者都email1@example.com
和email2@example.com
显示在至
字段中
我有什么办法可以使用email1@example.com
从“收件人”字段中删除,只显示在“回复”字段中指定的电子邮件地址
我正在使用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);
向地址添加回复^
默认情况下,回复地址将是发件人地址,除非您另行指定。这就是简单的电子邮件客户端智能。但是,您可以将电子邮件从一个电子邮件地址发送到另一个电子邮件地址,然后将任何回复发送到另一个电子邮件地址。以下是方法:
$mailer->AddReplyTo('billing@yourdomain.com","结算部",代码>
注:
您可以有多个回复地址,只需复制前面代码示例中的行并更改每行上的电子邮件地址即可
您需要在发件人地址前添加此行。P
根据这些示例,您的代码应该如下所示
$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);
尝试:
尝试在SetFrom之前先设置AddReplyTo()。phpmailer需要更改此行为。它将“发件人地址”添加到“答复收件人”字段。如果您在“发件人地址”之前先设置“回复到第一”,则无法将“发件人地址”添加到“回复到”标题中。这听起来是个好主意,我会检查它并让您知道它是如何运行的。是的,但这是一种“黑客行为”,因此您不需要编辑phpmailer。如果您只需要发送普通电子邮件,也可以完全停止使用phpmailer并执行以下操作:mail('email1@example.com“,”邮件主题“,”邮件正文“,”发件人:发件人。address@example.com\重复:这个。reply@address.here"); 但是您的服务器必须配置为使用mail()。请注意,对$this->phpmailer->MsgHTML($MsgHTML)的调用会同时设置AltBody,因此会有效地清除前一行中设置的AltBody
$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);