server = new Server($server, $port != '' ? $port : null); $this->connection = $this->server->authenticate($user, $password); } public function getUnprocessedEmails() { $mailbox = $this->connection->getMailbox('INBOX'); $search = new SearchExpression(); // not older than 30days $today = new \DateTimeImmutable(); $thirtyDaysAgo = $today->sub(new \DateInterval('P30D')); $search->addCondition(new Since($thirtyDaysAgo)); return $mailbox->getMessages($search); } public function moveProcessed(MessageInterface $mail) { return $mail->move($this->connection->getMailbox('PROCESSED')); } public function moveFailed(MessageInterface $mail) { return $mail->move($this->connection->getMailbox('FAILED')); } }