PHP 邮件中的交付报告和阅读回执

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1078251/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 00:53:10  来源:igfitidea点击:

Delivery reports and read receipts in PHP mail

phpemail

提问by Conrad

Does anyone of you know off by hand what mail headers to add in order to get a read receipt and delivery report? This now being when you use the normal PHP mail function. No fancy add-on script / class like phpMail.

你们中有人知道要添加哪些邮件标题才能获得已读回执和送达报告吗?现在,当您使用普通的 PHP 邮件功能时。没有像 phpMail 这样的花哨的附加脚本/类。

回答by Daniel Rikowski

For the reading confirmations:

对于阅读确认:

You have to add the X-Confirm-Reading-Toheader.

您必须添加X-Confirm-Reading-To标题。

X-Confirm-Reading-To: <address>

For delivery confirmations:

对于交货确认:

You have to add the Disposition-Notification-Toheader.

您必须添加Disposition-Notification-To标题。

For usage details see RFC 3798.

有关使用详细信息,请参阅RFC 3798



General tip for stuff like this:

像这样的东西的一般提示:

Use the mail client of your choice to generate an e-mail with the desired parameters, send it to yourself and look at the mail source.

使用您选择的邮件客户端生成带有所需参数的电子邮件,将其发送给您自己并查看邮件源。

There you can find the necessary headers added by the feature you are looking for. Then read the RFC or google for specific details on the header in question.

在那里您可以找到由您正在寻找的功能添加的必要标题。然后阅读 RFC 或谷歌以了解有关标题的具体细节。

回答by Nik Adlin Fariz

Gmail blocks methods such as:

Gmail 会阻止以下方法:

img src="http://yourdomain/tracking.php?id=EMAIL_ID" width="0" height="0"

img src="http://yourdomain/tracking.php?id=EMAIL_ID" width="0" height="0"

This is because the image is retrieved from a proxy. Since the URL contains variables and not a real image file, the image will not be shown. The tracker would be useless.

这是因为图像是从代理中检索的。由于 URL 包含变量而不是真正的图像文件,因此不会显示图像。跟踪器将无用。

I've personally experienced this as I build my own newsletter system.

我在构建自己的时事通讯系统时亲身经历过这种情况。

回答by Ayoub

What you could also do is embed an img (assuming that you're sending the email as text/html) tag that has in its source the following:

您还可以做的是嵌入一个 img(假设您将电子邮件作为 text/html 发送)标签,其源代码如下:

<img src="http://yourdomain/tracking.php?id=EMAIL_ID" width="0" height="0" >

where tracking.php is a file that would be opened when the email is also opened (assuming images are activated) and then you can catch on your side the parameter idand check it against a stored id (database or file).

其中 tracking.php 是一个文件,当电子邮件也被打开时(假设图像被激活),然后你可以捕捉参数id并根据存储的 id(数据库或文件)检查它。

I am doing this for a newsletter manager to count the number of views.

我这样做是为了让时事通讯经理计算查看次数。

回答by sasdas

X-Confirm-Reading-To: Disposition-Notification-To: or Return-Receipt-To:

X-Confirm-Reading-To: Disposition-Notification-To: 或 Return-Receipt-To: