Skip to content

Commit 33fb444

Browse files
author
Tim Wichmann
committed
Replace imap_rcube library with curl call
This commit removes the imap_rcube library with a curl call to the imap endpoint. Since curl is a dependency of nextcloud this should not cause any issues. This closes #116 Signed-off-by: Tim Wichmann <tim@wichmann.online>
1 parent f5629eb commit 33fb444

4 files changed

Lines changed: 12 additions & 4152 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ tests/clover.xml
66

77
# packaged app
88
build/artifacts
9+
10+
.envrc

lib/imap.php

Lines changed: 10 additions & 14 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,21 +85,19 @@ 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);
97+
$info = curl_getinfo($ch);
98+
curl_close($ch);
10299

103100
if($canconnect) {
104-
$rcube->closeConnection();
105101
$uid = mb_strtolower($uid);
106102
$this->storeUser($uid, $groups);
107103
return $uid;

lib/imap/imap_rcube.changes2upstream

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

0 commit comments

Comments
 (0)