ZF-9798: Zend_Mail_Storage_Imap Iterator not implemented correctly when moving or removing messages

Description

This code

 
$mail = new Zend_Mail_Storage_Imap(array(...));

$anotherFolder = $mail->getFolders()->{'anotherFolder'};

foreach($mail as $messageId => $message) {
   /* Do Stuff With The Message */
   $mail->moveMessage($messageId,$anotherFolder);
}

will move the wrong messages and in the end it will throw an exception. The implementation of the Iterator interface doesn't adjust the $messageId to follow Imap folder changes, causing a mismatching between the indexes of the object "$mail" and of the Imap server.

Comments

No comments to display