summaryrefslogtreecommitdiff
path: root/classes/auth/imap.php
blob: 52664eb3ea958648d415c2020b77961d287eb7cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/* Requires php-imap
	Put the following options in config.php:

	define('IMAP_AUTH_SERVER', 'your.imap.server:port');
	define('IMAP_AUTH_OPTIONS', '/tls/novalidate-cert/norsh');
	// More about options: http://php.net/manual/ru/function.imap-open.php

 */

class Auth_Imap extends Auth_Base {

	function authenticate($login, $password) {

		if ($login && $password) {
			$imap = imap_open(
				"{".IMAP_AUTH_SERVER.IMAP_AUTH_OPTIONS."}INBOX",
				$login,
				$password);

			if ($imap) {
				imap_close($imap);

				return $this->auto_create_user($login);
			}
		}

		return false;
	}

}
?>