Skip to content

Commit

Permalink
Replace imap_rcube library with curl call
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tim Wichmann committed Feb 11, 2020
1 parent f5629eb commit 8d48ce9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4,153 deletions.
27 changes: 12 additions & 15 deletions lib/imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* See the COPYING-README file.
*/

use OCA\user_external\imap\imap_rcube;

/**
* User authentication against an IMAP mail server
*
Expand Down Expand Up @@ -87,31 +85,30 @@ public function checkPassword($uid, $password) {
$groups[] = $pieces[1];
}

$rcube = new imap_rcube();

$params = ["port"=>$this->port, "timeout"=>10];
$protocol = $this->sslmode ? "imaps" : "imap";
$url = "{$protocol}://{$this->mailbox}:{$this->port}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);

$params["ssl_mode"] = $this->sslmode ? $this->sslmode : null;
$params["force_caps"] = false;
$canconnect = $rcube->connect(
$this->mailbox,
$username,
$password,
$params
);
$canconnect = curl_exec($ch);

if($canconnect) {
$rcube->closeConnection();
curl_close($ch);
$uid = mb_strtolower($uid);
$this->storeUser($uid, $groups);
return $uid;
} else {
OC::$server->getLogger()->error(
'ERROR: Could not connect via roundcube lib: '.$rcube->error,
'ERROR: Could not connect to imap server via curl: '.curl_error($ch),
['app' => 'user_external']
);
}

curl_close($ch);

return false;
}
}
24 changes: 0 additions & 24 deletions lib/imap/imap_rcube.changes2upstream

This file was deleted.

Loading

0 comments on commit 8d48ce9

Please sign in to comment.