Skip to content

Commit b27d85a

Browse files
Merge pull request #228 from BjoKaSH/imap_log_failure_reason
Distinguish wrong credentials from other problems (IMAP)
2 parents e45b03e + 6948390 commit b27d85a

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

lib/IMAP.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,29 @@ public function checkPassword($uid, $password) {
106106
$uid = mb_strtolower($uid);
107107
$this->storeUser($uid, $groups);
108108
return $uid;
109+
} elseif ($errorcode === CURLE_COULDNT_CONNECT ||
110+
$errorcode === CURLE_SSL_CONNECT_ERROR ||
111+
$errorcode === 28) {
112+
# This is not defined in PHP-8.x
113+
# 28: CURLE_OPERATION_TIMEDOUT
114+
\OC::$server->getLogger()->error(
115+
'ERROR: Could not connect to imap server via curl: ' . curl_strerror($errorcode),
116+
['app' => 'user_external']
117+
);
118+
} elseif ($errorcode === 9 ||
119+
$errorcode === 67 ||
120+
$errorcode === 94) {
121+
# These are not defined in PHP-8.x
122+
# 9: CURLE_REMOTE_ACCESS_DENIED
123+
# 67: CURLE_LOGIN_DENIED
124+
# 94: CURLE_AUTH_ERROR)
125+
\OC::$server->getLogger()->error(
126+
'ERROR: IMAP Login failed via curl: ' . curl_strerror($errorcode),
127+
['app' => 'user_external']
128+
);
109129
} else {
110130
\OC::$server->getLogger()->error(
111-
'ERROR: Could not connect to imap server via curl: '.curl_error($ch),
131+
'ERROR: IMAP server returned an error: ' . $errorcode . ' / ' . curl_strerror($errorcode),
112132
['app' => 'user_external']
113133
);
114134
}

0 commit comments

Comments
 (0)