[imp] virtual domains with vpopmail & courier

jlewis@lewis.org jlewis@lewis.org
Tue, 23 Jul 2002 12:11:44 -0400 (EDT)


I've been searching the archives and this appears to be a FAQ but I didn't 
find any answers I was happy with.

I'm looking for a way to setup IMP 3.1 to deal with large numbers of 
virtual domains.  Currently, we're using sqwebmail, and everyone goes to 
the same URL and logs in as user@theirdomain.com.  

I don't care at this point whether people go to webmail.theirdomain.com
and log in as user, or go to hostingmail.ourdomain.com and log in as
user@theirdomain.com...but I don't want to have to add an entry to
servers.php for each domain and I don't want to have to setup a new
virtual host in the apache config for each domain.  IMP is running on a
separate dedicated system.  The mail server that handles virtual domains
is qmail/vpopmail/courier-imap, and users must log in as
user@theirdomain.com to get their mail via pop3 or imap.

I found one post suggesting the following

//This extracts the domain name like webmail.example.com to example.com
$this_domain=substr(getenv('HTTP_HOST'),strpos(getenv('HTTP_HOST'),'.')+1);
//append mail host to domain, most server with mail like mail.example.com
$this_mail_server='mail.'.$this_domain;
$this_mail_protocol='imap';
$this_mail_port=143;
$this_mail_folder='';
$this_mail_namespace='';
$this_mail_smtphost='localhost';
$this_mail_realm='webmail.'.$this_domain;

$servers[$this_domain] = array(
        'name' => $this_domain,
        'server' => $this_mail_server,
        'protocol' => $this_mail_protocol,
        'port' => $this_mail_port,
        'folders' => $this_mail_folder,
        'namespace' => $this_mail_namespace,
        'maildomain' => $this_domain,
        'smtphost' => $this_mail_smtphost,
        'realm' => $this_mail_realm,
        )

I played around with this last night, and it seems to mostly work.  I
setup a virtual host on the IMP system with a ServerAlias wwwmail.* hoping
to be able to go to http://wwwmail.somedomain.com/, but redirect.php
redirects me to ServerName, which isn't going to be the URL I put in the
browser.  So this method looks as if it may require setting up a
virtualhost for each domain (yuck).  Also, I had to log in as 
user@somedomain.com, and the only obvious problem I noticed was sent mail 
said (in the headers added by IMP) the message was from 
user@somedomain.com@wemail.ourdomain.com.

There were other messages about using imapuser to setup the servers entry, 
but they mentioned that the method stopped working some time ago.
 
Is there a prefered/recommended way to set IMP up to do this with minimal 
hacking at the code?

Once this is setup, I plan to use ipchains on the IMP server to limit 
which imap servers the system can talk to.  

----------------------------------------------------------------------
 Jon Lewis *jlewis@lewis.org*|  I route
 System Administrator        |  therefore you are
 Atlantic Net                |  
_________ http://www.lewis.org/~jlewis/pgp for PGP public key_________