2011-03-23 100 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; 
      } 


     } 

    } 

} 

退回的电子邮件地址连接到接收邮件服务器是在邮件的正文我将它反映给浏览器。