Solve bug when emails were marked for deletion but not added to deck

pull/25/head
Alex Puiu 2022-05-19 11:16:03 +03:00
rodzic 395d9ed512
commit 2ed824c91e
2 zmienionych plików z 15 dodań i 4 usunięć

Wyświetl plik

@ -10,7 +10,11 @@ use Mail2Deck\ConvertToMD;
$inbox = new MailClass();
$emails = $inbox->getNewMessages();
if(!$emails) return; // nothing to do
if(!$emails) {
// delete all messages marked for deletion and return
$inbox->expunge();
return;
}
for ($j = 0; $j < count($emails) && $j < 5; $j++) {
$structure = $inbox->fetchMessageStructure($emails[$j]);

Wyświetl plik

@ -80,15 +80,22 @@ class MailClass {
}
/**
* Deletes a mail
* Mark emails for deletion
*
* @param $email email id that you want to delete
* @param $email email number that you want to delete
*
* @return void
*/
public function delete(int $email)
{
imap_delete($this->inbox, $email);
imap_delete($this->inbox, imap_uid($this->inbox, $email), FT_UID);
}
/**
* Delete all messages marked for deletion
*/
public function expunge()
{
imap_expunge($this->inbox);
}
}