Skip to content

Commit e8ba4de

Browse files
Merge pull request #122 from rollbrettler/master
Replace imap_rcube library with curl call
2 parents f5629eb + 8d48ce9 commit e8ba4de

File tree

3 files changed

+12
-4153
lines changed

3 files changed

+12
-4153
lines changed

lib/imap.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* See the COPYING-README file.
99
*/
1010

11-
use OCA\user_external\imap\imap_rcube;
12-
1311
/**
1412
* User authentication against an IMAP mail server
1513
*
@@ -87,31 +85,30 @@ public function checkPassword($uid, $password) {
8785
$groups[] = $pieces[1];
8886
}
8987

90-
$rcube = new imap_rcube();
91-
92-
$params = ["port"=>$this->port, "timeout"=>10];
88+
$protocol = $this->sslmode ? "imaps" : "imap";
89+
$url = "{$protocol}://{$this->mailbox}:{$this->port}";
90+
$ch = curl_init();
91+
curl_setopt($ch, CURLOPT_URL, $url);
92+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
93+
curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
94+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
9395

94-
$params["ssl_mode"] = $this->sslmode ? $this->sslmode : null;
95-
$params["force_caps"] = false;
96-
$canconnect = $rcube->connect(
97-
$this->mailbox,
98-
$username,
99-
$password,
100-
$params
101-
);
96+
$canconnect = curl_exec($ch);
10297

10398
if($canconnect) {
104-
$rcube->closeConnection();
99+
curl_close($ch);
105100
$uid = mb_strtolower($uid);
106101
$this->storeUser($uid, $groups);
107102
return $uid;
108103
} else {
109104
OC::$server->getLogger()->error(
110-
'ERROR: Could not connect via roundcube lib: '.$rcube->error,
105+
'ERROR: Could not connect to imap server via curl: '.curl_error($ch),
111106
['app' => 'user_external']
112107
);
113108
}
114109

110+
curl_close($ch);
111+
115112
return false;
116113
}
117114
}

lib/imap/imap_rcube.changes2upstream

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)