Batch handling of moving messages should speed up production thing

This commit is contained in:
Karl Cordes 2010-05-06 14:42:12 +10:00
parent daa4abf828
commit 08cba65fd6

View file

@ -57,6 +57,8 @@ class VaultShell extends Shell {
$enquiryList[$enqNumber] = $id; $enquiryList[$enqNumber] = $id;
} }
$storedArray = array();
$discardArray = array();
@ -154,9 +156,9 @@ class VaultShell extends Shell {
} }
echo "Email stored in the DB under enquiry ID".$enqID." Will be moved to the stored folder\n"; echo "Email stored in the DB under enquiry ID".$enqID." Will be moved to the stored folder\n";
if($testing == 0) { $storedArray[] = $i;
imap_mail_move($mbox, $i, 'INBOX/Stored');
}
} }
else { else {
echo 'Unable to save the Email\n'; echo 'Unable to save the Email\n';
@ -169,15 +171,33 @@ class VaultShell extends Shell {
* I may change this to simply delete the emails. This will do for now, but it's doubling up on the storage for useless files. * I may change this to simply delete the emails. This will do for now, but it's doubling up on the storage for useless files.
* */ * */
if($testing == 0 ) { $discardArray[] = $i;
imap_mail_move($mbox, $i, 'INBOX/Discarded');
}
} }
} }
/* Finished working with the IMAP server. Make the changes and close the connection */ /* Finished working with the IMAP server. Make the changes and close the connection */
if($testing == 0) {
reset($discardArray);
reset($storedArray);
$storeSet = implode(",", $storedArray);
$discardSet = implode(",",$discardArray);
echo "Tidying up now. Moving messages to Stored or Discarded\n";
imap_mail_move($mbox, $storeSet, 'INBOX/Stored');
imap_mail_move($mbox, $discardSet, 'INBOX/Discarded');
}
imap_expunge($mbox); imap_expunge($mbox);
imap_close($mbox); imap_close($mbox);
} }