获取邮件应用程序来识别回复电子邮件 php

发布于 2024-12-19 12:36:58 字数 954 浏览 4 评论 0原文

我不知道如何让邮件应用程序(谷歌邮件除外)识别电子邮件是作为“回复”发送的,并将这些电子邮件分组在一起作为已发送和回复电子邮件的列表。

例如,使用php,如果我使用

$header = "From: Testing <[email protected]>\r\n" .
                "Reply-To: [email protected]\r\n" . 
                "X-Mailer: PHP/" . phpversion();

$to = "[email protected]";

$message = "This is a reply";
$subject = "test 123";  
$success = mail($to, $subject, $message, $header);


发送两次,我收到两封单独的电子邮件。而不是由两封电子邮件组成一封电子邮件。
有没有办法将它们组合在一起,当一封电子邮件回复另一封电子邮件时,或者我做错了什么?
我已经阅读了 php mail() 文档和多个解释 php mail 如何工作的网页,但仍然无法让电子邮件相互回复。

感谢您的时间和帮助!

I can't figure out how to get a mail application (except google mail) to recognize that an email was sent as a "Reply-To" and have those emails grouped together as one list of sent and replied emails.

For example, using php, if I use

$header = "From: Testing <[email protected]>\r\n" .
                "Reply-To: [email protected]\r\n" . 
                "X-Mailer: PHP/" . phpversion();

$to = "[email protected]";

$message = "This is a reply";
$subject = "test 123";  
$success = mail($to, $subject, $message, $header);

And send this twice, I get two separate emails. Instead of one email composed of the two emails.

Is there a way to have them both grouped together as one email replied to another, or am I doing something wrong?

I've read the php mail() documentation and multiple webpages explaining how php mail works and still can't get the emails to reply to each other.

Thank you for your time and help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

英雄似剑 2024-12-26 12:36:59

回复标头用于指示应将回复发送到与发件人标头中的电子邮件地址不同的电子邮件地址。

我认为如果消息正文的一部分包含以前发送或回复消息的一部分的文本,或者主题包含 Re: 并与另一组消息中的主题匹配,Google 会采用一种算法将消息分组在一起。但回复标头可能对将消息分组为回复没有影响。

The reply-to header is used to indicate a reply should be sent to a different email address than the one in the from header.

I think Google employs an algorithm to group messages together if part of the message body contains text that was part of a previously sent or replied to message, or if the subject contains Re: and matches a subject from another group of messages. But the reply-to header probably has no effect on grouping messages as a reply.

紫瑟鸿黎 2024-12-26 12:36:59

我看这里没有问题。发送两封电子邮件导致收到两封电子邮件。这是预期的行为。 GMail 将它们分组在 UI 中的一个线程中,但在幕后,甚至 GMail 也将它们视为两个单独的消息。这完全独立于 Reply-To 标头。

I see no problem here. Two emails sent results in two emails received. This is the expected behavior. GMail is grouping them together in a thread in the UI, but under the hood, even GMail treats these as two separate messages. This is all totally independent of the Reply-To header.

地狱即天堂 2024-12-26 12:36:58

大多数邮件客户端通过检查 Message-IDIn-Reply-ToReferences 标头来处理线程。在第一条消息中,设置 Message-ID 标头,然后使用与 ReferencesIn-Reply-To 标头相同的值。邮件客户端应通过定位原始 Message-ID 并将其与具有相关 ReferencesIn-Reply-To 标头的消息进行匹配来对它们进行分组。

第一条消息:

// Create a unique value for message id based on time, random value, and the hostname
$message_id = md5(time() . rand()) . $_SERVER['HTTP_HOST'];

// Use as a header when constructing the email
Message-Id: $message_id

第二条消息:

// Use the same value as these two headers when constructing the reply message.
References: $message_id
In-Reply-To: $message_id

// Also, you should set a new unique message-id for this one
$new_message_id = md5(time() . rand()) . $_SERVER['HTTP_HOST'];
Message-ID: $new_message_id;

Most mail clients handle threading by examining the Message-ID, In-Reply-To, and the References headers. In your first message, set a Message-ID header, then use the same value as the References and In-Reply-To headers. The mail clients should group them by placing locating the original Message-ID and matching it with messages having related References and In-Reply-To headers.

First message:

// Create a unique value for message id based on time, random value, and the hostname
$message_id = md5(time() . rand()) . $_SERVER['HTTP_HOST'];

// Use as a header when constructing the email
Message-Id: $message_id

Second message:

// Use the same value as these two headers when constructing the reply message.
References: $message_id
In-Reply-To: $message_id

// Also, you should set a new unique message-id for this one
$new_message_id = md5(time() . rand()) . $_SERVER['HTTP_HOST'];
Message-ID: $new_message_id;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文