[imp] Setting up Imp 3.1 on Virtual Webhosting Box (for addition to faq)

Chris Bond chris@logics.co.uk
Fri, 20 Sep 2002 19:35:46 +0100


We host several virtual domains on our box.  In our example we wanted
our  customers to go to http://www.theredomainname.com/webmail.  From
there we wanted them to type there username and password.
 
Here's what we did to make this happen.

1. Edited httpd.conf and added the following line:
Alias /Webmail /usr/share/horde/imp

You need to restart apache to make these changes take effect
(/etc/init.d/httpd restart works well usually)

2. Edited /usr/share/horde/imp/config/servers.php and commented out all
the examples including the $servers['_prompt'] part.

Then you add the following to the file:

$this_domain=substr(getenv('HTTP_HOST'),strpos(getenv('HTTP_HOST'),'.')+
1);

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

3. Edited /usr/share/horde/imp/config/conf.php.

Changed $conf['server']['server_list'] = 'none';
to 'hidden'.

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

In my case my imap server expects the syntax of  username@domain.com (I
use ensim 3.1 which modifies the system to work in this way).

To do this you need to modify the imp_get_vinfo which is commented out
as it defaults to username_domain_com.  Also by default it expects a
subdomain like webmail.domain.com.  I don't want this I just want it to
pick it up from there domain so I need to change this to www.

In effect the function turned out like this changed about 2 lines of
code:

if (!function_exists('imp_get_vinfo')) {
     function imp_get_vinfo ($type = 'username') {
         global $conf, $imp;

         $vdomain = getenv('HTTP_HOST');
         $vdomain = preg_replace('|^www\.|i', '', $vdomain);
         $vdomain = strtolower($vdomain);

         if ($type == 'username') {
            return $imp['user'] . '@' . $vdomain;
             //return preg_replace('|\.|', '_', $imp['user'] . '_' .
$vdomain);
         } elseif ($type == "vdomain") {
             return $vdomain;
         } else {
             return new PEAR_Error('invalid type: ' . $type);
         }
     }
 }

I hope this helps some people out there as I found it quite hard to
patch this information together quickly, I hope you consider adding it
to the FAQ.

Kind Regards,
Chris Bond