簡體   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我想

我需要一份交貨報告

我的 PHP 版本是 7.3

我的 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;
}

有什么方法可以獲取成功發送或失敗的消息?

對於交貨確認:

您必須添加Disposition-Notification-To header。

有關使用詳情,請參閱RFC 3798

像這樣的東西的一般提示:

使用您選擇的郵件客戶端生成帶有所需參數的電子郵件,將其發送給您自己並查看郵件源。

在那里,您可以找到您正在尋找的功能添加的必要標題。 然后閱讀 RFC 或 google 以了解有關 header 的具體細節。

參考: PHP 郵件中的投遞報告和已讀回執

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM