4

我有一个 SMTP 问题。我创建了一个 PHP 脚本来发送电子邮件。要求是我需要从“email1@example.com”发送电子邮件,但我需要回复到“email2@example.com”

我已email2@example.comreply-to标题字段中添加。我遇到的唯一问题是,当有人收到电子邮件并单击回复按钮时,两者email1@example.comemail2@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);
4

2 回答 2

8

尝试:

$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 需要改变这种行为。它将发件人地址添加到回复字段。如果您在发件人地址之前先设置回复,它将无法将您的发件人地址添加到回复标头。

于 2012-08-27T15:59:01.933 回答
0

来自谷歌搜索和第一个结果

添加回复地址 ^

默认情况下,回复地址将是 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);
于 2012-08-27T15:56:02.573 回答