2011-03-23 97 views
1

我想跟蹤從我的服務器發送的已退回的電子郵件。我讀了幾件東西,發現反彈的電子郵件存儲在郵箱中,可以通過直接讀取郵箱文件來檢測。我如何跟蹤退回的電子郵件?

check for bounced mails with php

現在,我想我怎麼看我的服務器的郵箱文件得到一些想法?發送郵件以將退回的電子郵件記錄到我的數據庫後,是否需要手動運行php腳本文件?我是否需要分析電子郵件內容以找出哪些電子郵件已被反彈?

我的目標是我的php服務器的東西,用流行電子郵件訪問。

回答

1

這裏是我在one.com

$inbox = imap_open('{imap.one.com:993/imap/ssl/novalidate-cert}INBOX', '[email protected]', 'xxxxxxxx') or die('Cannot connect: ' . print_r(imap_errors(), true)); 

/* grab emails */ 
$emails = imap_search($inbox,'ALL'); 

/* if emails are returned, cycle through each... */ 
if($emails) { 

    /* put the newest emails on top */ 
    rsort($emails); 

    /* for every email... */ 
    foreach($emails as $email_number) { 

     $message = imap_fetchbody($inbox,$email_number,2); 

     $pieces = explode(" ", $message); 

     foreach($pieces as $piece){ 

      $findme = '@'; 
      //$findme2 = '.com'; 

      $pos = strpos($piece, $findme); 

      if ($pos !== false) { 
        echo $piece; 
      } 


     } 

    } 

} 

退回的電子郵件地址連接到接收郵件服務器是在郵件的正文我將它反映給瀏覽器。