diff --git a/webui/config.php b/webui/config.php index bc5ba2b3..f7b3cb8f 100644 --- a/webui/config.php +++ b/webui/config.php @@ -99,6 +99,12 @@ $config['IMAP_HOST'] = 'mail.yourdomain.com'; $config['IMAP_PORT'] = 993; $config['IMAP_SSL'] = true; +// enable authentication against a pop3 server (disabled by default) + +$config['ENABLE_POP3_AUTH'] = 0; +$config['POP3_HOST'] = 'mail.yourdomain.com'; +$config['POP3_PORT'] = 995; +$config['POP3_SSL'] = true; // enable authentication against google (disabled by default) // see http://www.mailpiler.org/en/google-apps-free.html for details diff --git a/webui/model/user/auth.php b/webui/model/user/auth.php index c317fad9..20aea2ac 100644 --- a/webui/model/user/auth.php +++ b/webui/model/user/auth.php @@ -18,6 +18,11 @@ class ModelUserAuth extends Model { if($ok == 1) { return $ok; } } + if(ENABLE_POP3_AUTH == 1) { + require 'Zend/Mail/Protocol/Pop3.php'; + $ok = $this->checkLoginAgainstPOP3($username, $password); + if($ok == 1) { return $ok; } + } // fallback local auth @@ -255,6 +260,34 @@ class ModelUserAuth extends Model { } + private function checkLoginAgainstPOP3($username = '', $password = '') { + $user = array(); + $rc = 0; + + try { + $conn = new Zend_Mail_Protocol_Pop3(POP3_HOST, POP3_PORT, POP3_SSL); + + if($conn) { + $s = $conn->connect(POP3_HOST); + + if($s) { + + try { + $conn->login($username, $password); + + $this->add_session_vars($username, $username, array($username), 0); + $rc = 1; + } + catch (Zend_Mail_Protocol_Exception $e) {} + } + } + } + catch (Zend_Mail_Protocol_Exception $e) {} + + return $rc; + } + + public function check_ntlm_auth() { $ldap_mail_attr = 'mail'; $ldap_account_objectclass = 'user';