Example #1
0
 /**
  * Scan the mailbox for new mails an sort them into the folders
  */
 public function scan()
 {
     // Read all messaged into an array:
     $mailsIds = $this->mailbox->searchMailbox('ALL');
     if (!$mailsIds) {
         die;
     }
     $this->initDatabase();
     foreach ($mailsIds as $mailId) {
         $mail = $this->mailbox->getMail($mailId, false);
         $folder = $this->database->findFolderBySender($mail->fromAddress);
         if (is_string($folder) && !empty($folder)) {
             $this->mailbox->moveMailToFolder($mailId, $folder);
             continue;
         }
         if ($this->checkAgainstPrivateBlacklist($mail->fromAddress)) {
             $this->mailbox->moveMailToFolder($mailId, 'INBOX/Junk');
             continue;
         }
         if ($this->checkAgainstPublicBlacklist($mailId)) {
             $this->mailbox->moveMailToFolder($mailId, 'INBOX/Junk');
             continue;
         }
         $this->database->createUndefinedSender($mail->fromAddress);
     }
 }