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,6 +870,9 @@ 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);
$prefix = $this->getMailboxPrefix();
$list = imap_list($imapConnection, "{" . $imap_server_address . "}", $prefix . $this->getSep() . $uid);
if (empty($list)) {
$createErrors = $this->createMailbox($imapConnection, $uid, $email_domain); $createErrors = $this->createMailbox($imapConnection, $uid, $email_domain);
$errors = array_merge($errors, $createErrors); $errors = array_merge($errors, $createErrors);
if (empty($createErrors)) { if (empty($createErrors)) {
@ -877,6 +880,7 @@ class imapAccess extends baseModule {
$errors = array_merge($errors, $quotaErrors); $errors = array_merge($errors, $quotaErrors);
} }
} }
}
if ($imapConnection) { if ($imapConnection) {
imap_close($imapConnection); imap_close($imapConnection);
} }