简体   繁体   English

确定真正的邮件发送状态(PHP mail())

[英]determine true mail sent status (PHP mail())

I am using inbuilt support of sending mails in php. 我正在使用内置支持在PHP中发送邮件。

$status=mail($to,$subject,$message,$headers,"-f $from");

I am on LAMP server and we use sendmail Unix utility. 我在LAMP服务器上,我们使用sendmail Unix实用程序。 php mail() returns true status if it has handed over the mail to sendmail so we can not be sure that whether a mail has been sent successfully of not. php mail()如果已将邮件移交给sendmail,则返回true状态,​​因此我们无法确定邮件是否已成功发送。 Now what I want is to make some socket connection between php and sendmail so that I can get the "True status" whether mail has been sent or not. 现在我想要的是在php和sendmail之间建立一些套接字连接,以便我可以获得“真实状态”,无论邮件是否已被发送。

I am very new for PHP. 我是PHP的新手。 This is the part of the first problem which I am solving in PHP. 这是我在PHP中解决的第一个问题的一部分。 I Goggled but I am not getting exactly how to proceed further. 我戴上眼镜但是我没有准确地知道如何继续前进。 Guide me how can I get true status whether a mail has been sent or not at PHP end? 指导我如何在PHP结束时获取邮件是否已发送的真实状态?

It won't get you anywhere if you check that your local sendmail demon has received the mail. 如果您检查您的本地sendmail恶魔收到了邮件,它将无法到达任何地方。 The important part would be that sendmail was able to forward the mail to another mail server. 重要的部分是sendmail能够将邮件转发到另一个邮件服务器。

But this really is also only half of the truth, because that server need not be the final destination of the mail. 但这实际上也只是事实的一半,因为该服务器不一定是邮件的最终目的地。 So after the mail left your sendmail demon, you cannot say anything about whether or not the mail reached it's destination or not. 因此,在邮件离开你的sendmail恶魔之后,你无法说明邮件是否到达目的地。

If you need to be sure, do the obvious thing: Include a link in the mail that needs to be clicked. 如果您需要确定,请执行显而易见的事情:在邮件中包含需要单击的链接。

Otherwise, assume your local sendmail is working (probably monitor if it really is), and simply send the mail. 否则,假设您的本地sendmail正在运行(可能监视它是否真的如此),并且只是发送邮件。

Option 1: Socket connection: read the RFC , then write a standards-compliant SMTP client program. 选项1:套接字连接: 读取RFC ,然后编写符合标准的 SMTP客户端程序。 [don't even bother unless you want to throw a few weeks of your life away] [除非你想要放弃几周的生命,否则不要打扰]

Option 2: Use PHPmailer or SwiftMailer or one of the other bazillion mailing libraries that have already written a standards-compliant SMTP client that will actually tell you if the mail was successfully sent or not. 选项2:使用PHPmailerSwiftMailer或已编写符合标准的SMTP客户端的其他bazillion邮件库之一,它实际上会告诉您邮件是否已成功发送。

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

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