我有一个 SMTP 问题。我创建了一个 PHP 脚本来发送电子邮件。要求是我需要从“email1@example.com”发送电子邮件,但我需要回复到“email2@example.com”
我在 reply-to
header 字段中添加了 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 需要改变这种行为。它将发件人地址添加到回复字段。如果您在发件人地址之前先设置回复,它将无法将您的发件人地址添加到回复标题。
关于php - 在电子邮件中设置回复字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12145168/