diff --git a/bl-plugins/imap-authentication/languages/de.json b/bl-plugins/imap-authentication/languages/de.json
index b5218a2c..9c7d8beb 100644
--- a/bl-plugins/imap-authentication/languages/de.json
+++ b/bl-plugins/imap-authentication/languages/de.json
@@ -3,6 +3,7 @@
{
"name": "IMAP-Authentifizierung",
"description": "Dieses Plugin ermöglicht die Authentifizierung von Benutzern mit Hilfe eines IMAP-Servers.",
- "imap-server": "IMAP Server"
+ "imap-server": "IMAP Server",
+ "encryption": "Verschlüsselung"
}
}
diff --git a/bl-plugins/imap-authentication/languages/en.json b/bl-plugins/imap-authentication/languages/en.json
index 7225dba2..2c551de1 100644
--- a/bl-plugins/imap-authentication/languages/en.json
+++ b/bl-plugins/imap-authentication/languages/en.json
@@ -3,6 +3,7 @@
{
"name": "IMAP Authentication",
"description": "This plugin enables the authentication of users, using an IMAP server.",
- "imap-server": "IMAP Server"
+ "imap-server": "IMAP Server",
+ "encryption": "Encryption"
}
}
diff --git a/bl-plugins/imap-authentication/plugin.php b/bl-plugins/imap-authentication/plugin.php
index 47fd2f1e..78754310 100644
--- a/bl-plugins/imap-authentication/plugin.php
+++ b/bl-plugins/imap-authentication/plugin.php
@@ -3,11 +3,13 @@
class pluginImapAuthentication extends Plugin {
const IMAP_SERVER_DB_FIELD = 'imapServer';
+ const IMAP_ENCRYPTION_DB_FIELD = 'imapEncryption';
public function init()
{
$this->dbFields = array(
self::IMAP_SERVER_DB_FIELD=>'',
+ self::IMAP_ENCRYPTION_DB_FIELD=>'ssl',
);
}
@@ -24,6 +26,14 @@ class pluginImapAuthentication extends Plugin {
$html .= '';
$html .= '';
+ $html .= '
';
+ $html .= '';
+ $html .= '';
+ $html .= '
';
+
return $html;
}
@@ -58,7 +68,7 @@ class pluginImapAuthentication extends Plugin {
$username = $_POST['username'];
$password = $_POST['password'];
- if (!$this->authenticateUser($this->getValue(self::IMAP_SERVER_DB_FIELD), $username, $password)) {
+ if (!$this->authenticateUser($this->getValue(self::IMAP_SERVER_DB_FIELD), $this->getValue(self::IMAP_ENCRYPTION_DB_FIELD), $username, $password)) {
return;
}
@@ -71,11 +81,12 @@ class pluginImapAuthentication extends Plugin {
/**
* @param $mailbox
+ * @param $encryption
* @param $username User's mail address
* @param $password
* @return bool
*/
- private function authenticateUser($mailbox, $username, $password)
+ private function authenticateUser($mailbox, $encryption, $username, $password)
{
if (!function_exists('imap_open')) {
Log::set(__METHOD__.LOG_SEP.'ERROR: PHP imap extension is not installed');
@@ -87,7 +98,7 @@ class pluginImapAuthentication extends Plugin {
$username = str_replace("%40","@",$username);
}
- $imapConnection = @imap_open("{{$mailbox}/imap/tls}INBOX", $username, $password, OP_HALFOPEN, 1);
+ $imapConnection = @imap_open("{{$mailbox}/imap/{$encryption}}INBOX", $username, $password, OP_HALFOPEN, 1);
$imapErrors = imap_errors();
$imapAlerts = imap_alerts();
if (!empty($imapErrors)) {
@@ -114,7 +125,7 @@ class pluginImapAuthentication extends Plugin {
{
global $users;
- if (!$this->authenticateUser($this->getValue(self::IMAP_SERVER_DB_FIELD), $username, $password)) {
+ if (!$this->authenticateUser($this->getValue(self::IMAP_SERVER_DB_FIELD), $this->getValue(self::IMAP_ENCRYPTION_DB_FIELD), $username, $password)) {
return;
}