try {
$this->client->login();
mtrace("Connection established.");
+
+ // Ensure that mailboxes exist.
+ $this->ensure_mailboxes_exist();
+
return true;
} catch (\Horde_Imap_Client_Exception $e) {
return in_array($flag, $flags);
}
+ /**
+ * Ensure that all mailboxes exist.
+ */
+ private function ensure_mailboxes_exist() {
+ $requiredmailboxes = array(
+ self::MAILBOX,
+ self::CONFIRMATIONFOLDER,
+ );
+
+ $existingmailboxes = $this->client->listMailboxes($requiredmailboxes);
+ foreach ($requiredmailboxes as $mailbox) {
+ if (isset($existingmailboxes[$mailbox])) {
+ // This mailbox was found.
+ continue;
+ }
+
+ mtrace("Unable to find the '{$mailbox}' mailbox - creating it.");
+ $this->client->createMailbox($mailbox);
+ }
+ }
+
/**
* Attempt to determine whether this message is a bulk message (e.g. automated reply).
*