我有一个SMTP问题。我已经创建了一个PHP脚本来发送电子邮件。要求是我需要从email1@example.com"但我需要回复"email2@example.com'
我已经在reply-to
报头字段中添加了email2@example.com
。我遇到的唯一问题是,当有人收到电子邮件并单击回复按钮时,email1@example.com
和email2@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);
尝试:
$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);
请尝试在SetFrom之前先设置AddReplyTo()。phpmailer需要更改这种行为。它将发件人地址添加到回复到字段中。如果在发件人地址之前先将"答复"设置为"第一个",则它将无法将您的发件人地址添加到"答复"标头中。
从谷歌搜索和第一个结果
添加回复地址^
默认情况下,回复地址将是FROM地址,除非您另有指定。这只是电子邮件客户端智能。但是,您可以让电子邮件来自一个电子邮件地址,任何回复都会转到另一个地址。方法如下:
$mailer->AddReplyTo('billing@yourdomain.com', 'Billing Department');
注意:您可以有多个回复地址,只需复制上一个代码示例中的行,然后更改每行的电子邮件地址。
您需要在发件人地址之前添加此行。请查看此项以了解同一问题的解决方案。
根据这些示例,您的代码应该看起来像
$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);