--- backend/imap.php.orig 2013-03-27 14:28:03.231378003 +0100 +++ backend/imap.php 2013-03-27 15:01:04.395096310 +0100 @@ -65,6 +65,48 @@ * default backend methods */ + public function email2user($p) + { + $r = $this->findinvirtual('/^' . preg_quote($p, '/') . '\s/'); + + for ($i=0; $i 0) { + $res = trim($arr[count($arr)-1]); + break; + } + } + + return $res; + } + + public function findinvirtual($pattern) + { + $file = "/etc/mail/virtual"; + $result = array(); + $virtual = null; + + if ($file) + $virtual = file($file); + + if (empty($virtual)) + return $result; + + // check each line for matches + foreach ($virtual as $line) { + $line = trim($line); + if (empty($line) || $line[0]=='#') + continue; + + if (preg_match($pattern, $line)) + $result[] = $line; + } + + return $result; + } + + /** * Authenticates the user * @@ -84,6 +126,10 @@ if (!function_exists("imap_open")) throw new FatalException("BackendIMAP(): php-imap module is not installed", 0, null, LOGLEVEL_FATAL); + # if username is a full email, try to find out the real user + if (preg_match("/@/", $username)) + $username = $this->email2user($username); + /* BEGIN fmbiete's contribution r1527, ZP-319 */ $this->excludedFolders = array(); if (defined('IMAP_EXCLUDED_FOLDERS')) { @@ -1804,4 +1850,4 @@ /* END fmbiete's contribution r1528, ZP-320 */ }; -?> \ Brak znaku nowej linii na końcu pliku +?>