[imp] multiple imap servers

Jan Schneider jan at horde.org
Tue Jul 10 22:33:29 UTC 2012


Zitat von jason kawaja <kawaja at ece.ufl.edu>:

> greetings list, been running version 3 for a long while and i must  
> be missing something obvious as i was reading  
> http://wiki.horde.org/ImapSelect and have the following in my setup :
>
> horde/imp/config/conf.php
>
> <?php
> $conf['hooks']['preauthenticate'] = true;
> ...
>
> horde/imp/config/hooks.php
>
> <?php
>
> if (!function_exists('_horde_hook_preauthenticate')) {
>     function _horde_hook_preauthenticate($userID, $credential, $realm)
>     {
>         require dirname(__FILE__) . '/../imp/config/servers.php';
>
>         // Convert all to lower chars (even the possible domain part)
>         $userID=strtolower($userID);
>         // Strip domain part from user, if it exists.
>         if (($domainpart = strpos($userID, '@'))) {
>           $server=substr($userID, $domainpart+1);
>           $userID=substr($userID, 0, $domainpart);
>           // Change the values only if a domain part was found ...
>           if (!empty($server)) {
>             foreach ($servers as $serverkey => $curServer) {
>               if (!empty($curServer['realm']) && $server ==  
> $curServer['realm']) {
>                 // We found an entry, now set IMAP server values.
>                 foreach (array('server', 'folders', 'namespace',
>                   'protocol', 'port', 'smtphost', 'smtpport',  
> 'maildomain') as $key) {
>                   if (isset($servers[$serverkey][$key])) {
>                     $_SESSION['imp'][$key] = $servers[$serverkey][$key];
>                   }
>                 }
>                 // Now use only the stripped version of the userID  
> to logon to the server
>                 $_SESSION['imp']['user'] = $userID;
>                 // Setup the correct base_protocol
>                 $_SESSION['imp']['base_protocol'] =  
> $_SESSION['imp']['protocol'];
>                 if (($pos = strpos($_SESSION['imp']['protocol'], '/'))) {
>                   $_SESSION['imp']['base_protocol'] =  
> substr($_SESSION['imp']['protocol'], 0, $pos);
>                 }
>               }
>             }
>           }
>         }
>         return true;
>     }
> }
>
> ...
>
> horde/imp/config/servers.php
>
> $servers['svr1'] = array(
>     'name' => 'SVR1',
>     'server' => 'SVR1.ece.ufl.edu',
>     'hordeauth' => true,
>     'protocol' => 'imap/ssl/novalidate-cert',
>     'port' => 993,
>     'maildomain' => 'one.ece.ufl.edu',
>     'smtphost' => 'smtp1.ece.ufl.edu',
>     'smtpport' => 25,
>     'realm' => '',
>     'preferred' => 'true',
> );
>
> $servers['svr2'] = array(
>     'name' => 'SVR2',
>     'server' => 'SVR2.ece.ufl.edu',
>     'hordeauth' => true,
>     'protocol' => 'imap/ssl/novalidate-cert',
>     'port' => 993,
>     'maildomain' => 'two.ece.ufl.edu',
>     'smtphost' => 'smtp2.ece.ufl.edu',
>     'smtpport' => 25,
>     'realm' => 'two.ece.ufl.edu',
>     'preferred' => '',
> );
>
>
> i can login a user on svr1 but only if i do not include the domain  
> part (@svr1.ece.ufl.edu) and when i try to include the domain part  
> for svr2 there is no logon attempt on the svr2 server from webmail,  
> so its not even trying...let me know what else to post to assist,  
> thanks in advance...id like to put in a few different domains that  
> are selected automatically depending on @domain.tld in the username.

And what exactly is the problem? Is the code not reached where  
$_SESSION is overwritten, or does it not write the correct values?
-- 
Jan Schneider
The Horde Project
http://www.horde.org/



More information about the imp mailing list