modcache.sh: Support imap connections with tls/ssl
This commit is contained in:
parent
d3a6a40c25
commit
5f11d68ee7
1 changed files with 15 additions and 2 deletions
|
@ -210,9 +210,22 @@ function authenticate(&$opts)
|
||||||
else if (empty($opts['user']))
|
else if (empty($opts['user']))
|
||||||
$opts['user'] = $opts['username'];
|
$opts['user'] = $opts['username'];
|
||||||
|
|
||||||
|
// parse $host URL
|
||||||
|
$url = parse_url(trim($opts['host']));
|
||||||
|
if (!empty($url['host'])) {
|
||||||
|
$imap_host = $url['host'];
|
||||||
|
$imap_ssl = isset($url['scheme']) && in_array($url['scheme'], array('ssl','imaps','tls')) ? $url['scheme'] : false;
|
||||||
|
$imap_port = isset($url['port']) ? $url['port'] : ($imap_ssl && $imap_ssl != 'tls' ? 993 : 143);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$imap_host = trim($opts['host']);
|
||||||
|
$imap_port = 143;
|
||||||
|
$imap_ssl = false;
|
||||||
|
}
|
||||||
|
|
||||||
// let the kolab_auth plugin do its magic
|
// let the kolab_auth plugin do its magic
|
||||||
$auth = $rcmail->plugins->exec_hook('authenticate', array(
|
$auth = $rcmail->plugins->exec_hook('authenticate', array(
|
||||||
'host' => trim($opts['host']),
|
'host' => $imap_host,
|
||||||
'user' => trim($opts['user']),
|
'user' => trim($opts['user']),
|
||||||
'pass' => $opts['password'],
|
'pass' => $opts['password'],
|
||||||
'cookiecheck' => false,
|
'cookiecheck' => false,
|
||||||
|
@ -221,7 +234,7 @@ function authenticate(&$opts)
|
||||||
|
|
||||||
if ($auth['valid']) {
|
if ($auth['valid']) {
|
||||||
$storage = $rcmail->get_storage();
|
$storage = $rcmail->get_storage();
|
||||||
if ($storage->connect($auth['host'], $auth['user'], $auth['pass'], 143, false)) {
|
if ($storage->connect($imap_host, $auth['user'], $auth['pass'], $imap_port, $imap_ssl)) {
|
||||||
if ($opts['verbose'])
|
if ($opts['verbose'])
|
||||||
echo "IMAP login succeeded.\n";
|
echo "IMAP login succeeded.\n";
|
||||||
if (($user = rcube_user::query($opts['username'], $auth['host'])) && $user->ID)
|
if (($user = rcube_user::query($opts['username'], $auth['host'])) && $user->ID)
|
||||||
|
|
Loading…
Add table
Reference in a new issue