Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php跟踪跳转邮件?_Php_Email_Phpmailer - Fatal编程技术网

如何使用php跟踪跳转邮件?

如何使用php跟踪跳转邮件?,php,email,phpmailer,Php,Email,Phpmailer,因为我用php开发了批量电子邮件系统,所以我使用它来跟踪被退回的邮件。我用gmail服务器测试了它。脚本连接到服务器并列出收件箱中的所有邮件。我用错误的地址发送电子邮件,谷歌邮件返回发送状态通知。下面是一个输出示例 2:--Mail Delivery Subsystem---mailer-daemon@googlemail.com--0000 | unrecognized | none | not deleted | Mail Delivery Subsystem | Delivery Stat

因为我用php开发了批量电子邮件系统,所以我使用它来跟踪被退回的邮件。我用gmail服务器测试了它。脚本连接到服务器并列出收件箱中的所有邮件。我用错误的地址发送电子邮件,谷歌邮件返回发送状态通知。下面是一个输出示例

2:--Mail Delivery Subsystem---mailer-daemon@googlemail.com--0000 | unrecognized | none | not deleted | Mail Delivery Subsystem | Delivery Status Notification (Failure)hhhhh:
3:--Mail Delivery Subsystem---mailer-daemon@googlemail.com--0000 | unrecognized | none | not deleted | Mail Delivery Subsystem | Delivery Status Notification (Failure)hhhhh:
为此,我使用上面的回调操作

function callbackAction ($msgnum, $bounce_type, $email, $subject, $xheader, $remove, $rule_no=false, $rule_cat=false, $totalFetched=0) {

  if ( $remove == true || $remove == '1' ) {
    echo "note: sample code would have set the database to allowed='false'<br />";
  }
  $displayData = prepData($email, $bounce_type, $remove);
  $bounce_type = $displayData['bounce_type'];
  $emailName   = $displayData['emailName'];
  $emailAddy   = $displayData['emailAddy'];
  $remove      = $displayData['remove'];

  echo $msgnum . ':--'.$emailName. "---" .$emailAddy. "--". $rule_no . ' | '  . $rule_cat . ' | '  . $bounce_type . ' | '  . $remove . ' | ' . $email . ' | '  . $subject . "hhhhh:" . $xheader . "<br />\n";


  return true;
}
函数回调操作($msgnum、$bounce\u type、$email、$subject、$xheader、$remove、$rule\u no=false、$rule\u cat=false、$totalFetched=0){
如果($remove==true | |$remove=='1'){
echo“注意:示例代码会将数据库设置为allowed='false'
”; } $displayData=prepData($email、$bounce\u type、$remove); $bounce_type=$displayData['bounce_type']; $emailName=$displayData['emailName']; $emailAddy=$displayData['emailAddy']; $remove=$displayData['remove']; echo$msgnum.:-->.$emailName.-->.$emailAddy.-->.$rule_no.|.$rule_cat.|.$bounce_type.|.$remove.|.$email.|.$subject..hhhhh:$xheader.
\n; 返回true; }

脚本显示未送达的邮件,但我无法获取错误的电子邮件地址,因为我需要从数据库中删除错误的地址。如何查看电子邮件脚本返回daemon@googlemail.com. 这不是我发信息的邮件。有没有解决办法来获取错误的电子邮件地址?

您需要使用回调

function callbackAction ($msgnum, $bounce_type, $email, $subject, $xheader, $remove, $rule_no=false, $rule_cat=false, $totalFetched=0)
{
    $cleanEmail = someFunctionToSanitize($email);
    $sql = "DELETE FROM yourTable WHERE emailAddress = '" . $cleanEmail . "'";

    // call your function to execute the query here.
    // this is a simple example, using bound parameters in the query would be better
}
如果要使用不同的函数名,则必须让
bounceEmailHandler
对象知道

$bmh = new BounceMailHandler();
$bmh->action_function    = 'someNewFunctionName'; // default is 'callbackAction'