check mailbox before creation

This commit is contained in:
Roland Gruber 2018-08-12 10:39:24 +02:00
parent a35c4bc06d
commit ebe2c6390a
1 changed files with 9 additions and 5 deletions

View File

@ -870,11 +870,15 @@ class imapAccess extends baseModule {
$imapConnection = 0;//default state is false $imapConnection = 0;//default state is false
if ($imap_admin_password) { if ($imap_admin_password) {
$imapConnection = @imap_open("{" . $imap_server_address . "}", $imap_admin_user, $imap_admin_password, OP_HALFOPEN, 1); $imapConnection = @imap_open("{" . $imap_server_address . "}", $imap_admin_user, $imap_admin_password, OP_HALFOPEN, 1);
$createErrors = $this->createMailbox($imapConnection, $uid, $email_domain); $prefix = $this->getMailboxPrefix();
$errors = array_merge($errors, $createErrors); $list = imap_list($imapConnection, "{" . $imap_server_address . "}", $prefix . $this->getSep() . $uid);
if (empty($createErrors)) { if (empty($list)) {
$quotaErrors = $this->setQuota($imapConnection, $uid, $email_domain, $limit); $createErrors = $this->createMailbox($imapConnection, $uid, $email_domain);
$errors = array_merge($errors, $quotaErrors); $errors = array_merge($errors, $createErrors);
if (empty($createErrors)) {
$quotaErrors = $this->setQuota($imapConnection, $uid, $email_domain, $limit);
$errors = array_merge($errors, $quotaErrors);
}
} }
} }
if ($imapConnection) { if ($imapConnection) {