Merge pull request #122 from rollbrettler/master
Replace imap_rcube library with curl call
This commit is contained in:
27
lib/imap.php
27
lib/imap.php
@@ -8,8 +8,6 @@
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
use OCA\user_external\imap\imap_rcube;
|
||||
|
||||
/**
|
||||
* User authentication against an IMAP mail server
|
||||
*
|
||||
@@ -87,31 +85,30 @@ class OC_User_IMAP extends \OCA\user_external\Base {
|
||||
$groups[] = $pieces[1];
|
||||
}
|
||||
|
||||
$rcube = new imap_rcube();
|
||||
$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 = ["port"=>$this->port, "timeout"=>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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
commit 97dc6583c41605beda7eced3ba05fc578cfd6111
|
||||
Author: Scott Shambarger <devel@shambarger.net>
|
||||
Date: Wed May 29 20:07:18 2019 -0700
|
||||
|
||||
Fix Issue #56: Undefined Indices in Logs
|
||||
|
||||
Add ssl_mode and force_caps to connection params, and correctly handle
|
||||
AUTHENTICATE PLAIN in putLineC to reduce warnings in logs.
|
||||
|
||||
Signed-off-by: Scott Shambarger <devel@shambarger.net>
|
||||
|
||||
diff --git a/lib/imap/imap_rcube.php b/lib/imap/imap_rcube.php
|
||||
index f5b5b79..ceec1e5 100644
|
||||
--- a/lib/imap/imap_rcube.php
|
||||
+++ b/lib/imap/imap_rcube.php
|
||||
@@ -146,7 +146,7 @@ class imap_rcube
|
||||
$res = 0;
|
||||
if ($parts = preg_split('/(\{[0-9]+\}\r\n)/m', $string, -1, PREG_SPLIT_DELIM_CAPTURE)) {
|
||||
for ($i=0, $cnt=count($parts); $i<$cnt; $i++) {
|
||||
- if (preg_match('/^\{([0-9]+)\}\r\n$/', $parts[$i+1], $matches)) {
|
||||
+ if (isset($parts[$i+1]) && preg_match('/^\{([0-9]+)\}\r\n$/', $parts[$i+1], $matches)) {
|
||||
// LITERAL+ support
|
||||
if ($this->prefs['literal+']) {
|
||||
$parts[$i+1] = sprintf("{%d+}\r\n", $matches[1]);
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user