[imp] Using Virtual domain logins - IMAP

Eli eli@experthost.com
Fri, 23 Aug 2002 10:29:18 -0400


I have made alterations to IMP to allow this.  The patch isn't official,
and I don't know if the IMP people will even decide to use it, but yes,
it allows you to log in with your email address/password, and it does an
MX record lookup on the part after @ and tries to log you in to that MX
server.  If the MX lookup fails it just tries to log you in to the part
after @ directly (if someone uses the format user@mailserver, since the
mailserver won't have an MX record).

Here's what you have to change:

imp/config/servers.php (comment out all servers and just use this in the
file):

global $servers;

$servers['_prompt'] = array(
    'name' => 'Choose a mail server:'
);

$servers['imap'] = array(
    'name' => 'IMAP Server',
    'server' => '',
    'protocol' => 'imap/notls',
    'port' => 143,
    'folders' => '',
    'namespace' => '',
    'maildomain' => '',
    'smtphost' => '',
    'realm' => '',
    'preferred' => ''
);

imp/lib/IMP.php (line 40 - I just moved the include_once line):

        /* We might need to override some of the defaults with
           environmental settings. */
        include_once IMP_BASE . '/config/servers.php';

        /* Run the username through virtualhost expansion functions if
           necessary. */
        if (!empty($conf['hooks']['vinfo']) &&
function_exists($conf['hooks']['vinfo'])) {
            $imp['user'] = call_user_func($conf['hooks']['vinfo']);
        }

        $imp['pass'] = Secret::write(Secret::getKey('imp'),
Horde::getFormData('pass'));

imp/config/conf.php (this is a vinfo hook function):

$conf['hooks']['vinfo'] = 'imp_get_vinfo';

if (!function_exists('imp_get_vinfo')) {
    function imp_get_vinfo () {
        global $imp, $servers, $HTTP_POST_VARS;

        if (preg_match('/(.*)@([\w\-\.]+)$/', $imp['user'], $matches)) {
            /* $imp['user'] = $matches[1]; */
            $vdomain = strtolower($matches[2]);

            if (getmxrr($vdomain, $matches)) {
                $mserver = strtolower($matches[0]);
            }
            else {
                $mserver = $vdomain;
            }

            $servers["${HTTP_POST_VARS['server']}"]['server']     =
$mserver;
            $servers["${HTTP_POST_VARS['server']}"]['smtphost']   =
$mserver;
            $servers["${HTTP_POST_VARS['server']}"]['maildomain'] =
$vdomain;
        }

        return $imp['user'];
    }
}



You have to set your server list to be 'hidden'
($conf['server']['server_list'] = 'hidden';), but that's basically it.
The script sends the full email address as the username to log in - if
you want to send only the part before the @ for the username to log in
(to the IMAP server!), then uncomment the "$imp['user'] = $matches[1];"
part.

Eli.

> -----Original Message-----
> From: imp-bounces@lists.horde.org 
> [mailto:imp-bounces@lists.horde.org] On Behalf Of Bård Tommy Nilsen
> Sent: Friday, August 23, 2002 4:42 AM
> To: 'imp@lists.horde.org'
> Subject: [imp] Using Virtual domain logins - IMAP
> 
> 
> 
> 
> Hello !!
> 
> 
> I want to use virtual domain logins with imp, is it
> Possible ??
> 
> Using RedHat 7.2 with IMAP.....
> 
> Want users to log in with user@domain.com
> 
> Regards
> Bård Tommy Nilsen
> 
> -- 
> IMP mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe@lists.horde.org
>