在电子邮件中设置replyTo字段 [英] Setting replyTo field in email

查看:1076
本文介绍了在电子邮件中设置replyTo字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我添加了 email2@example.com reply-to 头字段中。我唯一的问题是,当有人收到电子邮件并点击回复按钮时, email1@example.com email2 @ example。 com 正在 TO 字段中显示。



有没有办法可以从TO字段中删除 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);


解决方案

尝试:

  $ 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需要改变这种行为。它将从地址添加到回复字段。如果您在来自地址之前设置了第一个回复,则无法将其从地址添加到回复标题。


I have an SMTP question. I have created a PHP script to send out emails. The requirement is that I need to send email from 'email1@example.com' but I need replies to come to 'email2@example.com'

I have added email2@example.com in the reply-to header field. The only problem I am having is that when someone receives the email and clicks on the reply button, both email1@example.com and email2@example.com are being shown in the TO field.

Is there any way that I can have email1@example.com removed from the TO field and only show the email address that was specified in the reply-to field?

I am using PHPMailer and the code is below:

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

解决方案

Try:

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

Try setting AddReplyTo() first before SetFrom. phpmailer needs to change this behavior. It adds the from address to the reply-to field. If you set reply-to first before the from address, it will not be able to add your from address to the reply-to header.

这篇关于在电子邮件中设置replyTo字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆