简体   繁体   English

跟踪SMTP使用PHP发送的电子邮件

[英]Track emails sent by SMTP with PHP

I'm developing a little email sender portal that allows registered users to send some amounts of emails. 我正在开发一个小的电子邮件发件人门户网站,允许注册用户发送一些电子邮件。 I use a secure connection with an SMTP server installed on localhost (I mean same server of Apache and PHP) to send the emails and I have implemented a system to take control on the amounts of emails sent (I schedule the sending of the emails to avoid sending too much emails at the same time). 我使用与localhost上安装的SMTP服务器的安全连接(我的意思是Apache和PHP的相同服务器)来发送电子邮件,我已经实现了一个系统来控制发送的电子邮件数量(我安排发送电子邮件到避免同时发送太多电子邮件)。

I use PHPMAiler class to send the emails and a class of my own to schedule them. 我使用PHPMAiler类发送电子邮件和我自己的类来安排它们。

The only thing I miss is to track the emails I've sent to know if some errors occured (and which error in particular ie. address not found, recipient mailbox full, etc...) and to know if the user opened the email and when. 我唯一想念的是跟踪我发送的电子邮件,知道是否发生了一些错误(特别是哪个错误,例如找不到地址,收件人邮箱已满等等),并知道用户是否打开了电子邮件什么时候。

I admit that I actually know almost nothing about SMTP servers, but I'd like to know if there are some resources where I can find a PHP class that can talk to the SMTP server to ask it for the sent emails, or if there's any way in PHP to retreive sent emails information.... or anything else that could be useful for my purposes. 我承认我实际上对SMTP服务器几乎一无所知,但是我想知道是否有一些资源我可以找到一个可以与SMTP服务器通信的PHP类,以询问它发送的电子邮件,或者是否有任何在PHP中检索发送的电子邮件信息....或其他任何可能对我的目的有用的东西。

Unfortunately there is no way to 'track' email once the SMTP server has send it to the recipients mailserver. 遗憾的是,一旦SMTP服务器将电子邮件发送到收件人邮件服务器,就无法“跟踪”电子邮件。

If the receiving email server encounters an error it will automatically send the error message to the sender address. 如果接收电子邮件服务器遇到错误,它将自动将错误消息发送到发件人地址。 This will probably be the e-mail adres of the registered user who tries the send the email. 这可能是尝试发送电子邮件的注册用户的电子邮件地址。

Hope this helps. 希望这可以帮助。

There is no way to track the email once it leaves however you do have two options. 一旦它离开,就无法跟踪电子邮件,但是您有两个选项。 One is to check for bounced messages. 一种是检查退回邮件。 Normally outgoing messages will specify a return-path that the bounces will go to. 通常,外发消息将指定退回将返回的返回路径。

The other option is that you do have control of the sending server. 另一个选择是您可以控制发送服务器。 If the server that you are sending to is the server that complains that the user is missing for example then you will receive one of the SMTP error codes. 如果您要发送到的服务器是抱怨用户丢失的服务器,那么您将收到一个SMTP错误代码。 SMTP error codes are pretty much the oposite to HTTP ones in that 500's are hard bounces (permanent errors like user is not known here) and 400's soft bounces (temporary errors). SMTP错误代码几乎与HTTP相反,因为500的硬反弹(像用户这里不知道的永久性错误)和400的软反弹(临时错误)。

Finally it is also possible to add a small image (that will render via your php script) to track opens of an email, obviously this won't help if the user blocks the images but it can provide some idea that the user has read the emails (along with link tracking) 最后,还可以添加一个小图像(将通过您的PHP脚本呈现)来跟踪电子邮件的打开,显然,如果用户阻止图像,这将无济于事,但它可以提供用户已阅读的一些想法电子邮件(以及链接跟踪)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM