2010-12-10 14 views
0

私はMaildirとPHPでちょっとした問題を抱えています。 APACHE_RUN_USERMaildirと、delivery-statusというメッセージを確認する必要があります。Maildirの電子メールメッセージをPHPから削除するには?

読み取り後のメッセージの削除に関する問題。私はZend_Mail_Storage_Maildir->removeMessage()がまだスタブであることに気づいた。

try { 
    $mailbox = new Zend_Mail_Storage_Maildir(array('dirname' => '/home/' . $_ENV['APACHE_RUN_USER'] . '/Maildir/')); 

    foreach ($mailbox as $id => $message) { 

     // seen flag 
     if ($message->hasFlag(Zend_Mail_Storage::FLAG_SEEN)) { continue; } 

     //get the unique id 
     $uniqueid = $mailbox->getUniqueId($id); 

     //obtain message headers 
     $headers = $message->getHeaders(); 

     //check if the original message was sent from this app and is a delivery-status 
     $result = strpos($message, $id_header); 
     if($result === false) { echo '1 mail skipped: ' . $uniqueid . '. <br />'; continue; } 

     $result = strpos($headers['content-type'], 'delivery-status'); 
     //if no skip to the next mail 
     if($result === false) { echo '1 mail skipped: ' . $uniqueid . '. <br />'; continue; } 

     // if everything it's ok process it. 

     // clear results 
     $data = array(); 
     // foreach line of message 
     foreach(preg_split('/(\r?\n)/', $message) as $line){ 
      //clear results 
      $matches = array(); 

      //perform matches on textlines 
      if(preg_match('/^(.+)\:\s{0,1}(.+)$/', $line, $matches)) { 
       //grab intrested headers 
       foreach(array('Action', 'Status', 'Remote-MTA', 'Diagnostic-Code', $id_header) as $header) { 
        if($matches[1] == $header) $data[$header] = $matches[2]; 
       } 
      } 
     } 

     // *** I NEED TO DROP THE MESSAGE HERE *** 

      // not working code *** 
     $currentmessageid = $mailbox->getNumberByUniqueId($uniqueid); 
     $mailbox->removeMessage($currentmessageid); 

     // *** I NEED TO DROP THE MESSAGE HERE *** 


    // print out results 
     echo '<pre class="email">'; 
     print_r($data); 
     echo '</pre>'; 
    } 

} catch (Exception $e) { 
    echo $e; 
} 

どうすれば削除できますか?いくつかの回避策?

ありがとうございました。

答えて

1

1

申し訳ありませんが、まだ実装されていません!

チェックアウト課題追跡を今日までhttp://framework.zend.com/issues/browse/ZF-9574

その未解決の問題が、いくつかのコメントが役に立つかもしれません:

1を使用する必要があります のmaildirまたはmbox形式のストレージからのメールを削除するためには: Zend_Mail_Storage_Writable_Maildirまたは Zend_Mail_Storage_Writable_Mbox

この の歴史的な理由があります。 d が標準化されています。今のところ上記の クラスを使用する必要があります。または という例外がスローされ、 というメッセージが表示されます。

詳しくは、 http://framework.zend.com/issues/browse/ZF-9574 を参照してください。

オープニングのメールボックス:

$mailbox = new Zend_Mail_Storage_Writable_Maildir(array('dirname' => '/home/' . $_ENV['APACHE_RUN_USER'] . '/Maildir/')); 

処理メールコード:私は次のように解決tawfekov答えのために

+0

おかげで、私はZend_Mail_Storage_Writable_Maildirクラスに置き換え解か。 –

関連する問題