简体   繁体   English

如何从 PHP 邮件 function 获取交货报告?

[英]How to get delivery report from PHP mail function?

I trying to send email using the PHP mail function but when I use fake email and it gives me no error and I cannot find out the email was sent or not I try all the ways from other similar question answers but I don't get what I want I trying to send email using the PHP mail function but when I use fake email and it gives me no error and I cannot find out the email was sent or not I try all the ways from other similar question answers but I don't get what我想

I need to get a delivery report我需要一份交货报告

my PHP version is 7.3我的 PHP 版本是 7.3

my PHP codes:我的 PHP 代码:

$to = 'example@somesite.com';

$subject = 'Message from ';

$message = $Message ;

$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';

$headers[] = 'To: '. $to;
$headers[] = 'From: <sombody@theresite.com>';

if(mail($to, $subject, $message, implode("\r\n", $headers))){
    echo 555;
}else{
   echo 444;
}

Is there any way to get message for successful sent or fail?有什么方法可以获取成功发送或失败的消息?

For delivery confirmations:对于交货确认:

You have to add the Disposition-Notification-To header.您必须添加Disposition-Notification-To header。

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 或 google 以了解有关 header 的具体细节。

Ref: Delivery reports and read receipts in PHP mail参考: PHP 邮件中的投递报告和已读回执

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

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