[imp] Imp setup issues.

Chris Bond chris@logics.co.uk
Fri, 20 Sep 2002 17:12:12 +0100


I've searched the lists and cannot find anything for 3.1...................
----- Original Message -----
From: "Eric Rostetter" <eric.rostetter@physics.utexas.edu>
To: "Chris Bond" <chris@logics.co.uk>
Cc: <imp@lists.horde.org>
Sent: Friday, September 20, 2002 4:47 PM
Subject: Re: [imp] Imp setup issues.


> Quoting Chris Bond <chris@logics.co.uk>:
>
> > Ok how do you do virtual hosts it says consult this list.
>
> Yes, consult the list archives.  But this really ought to be an FAQ.
> So, what I'm going to do is post here (below) some previous messages
> from the list.  My hope is that:
>
> * This will help you.
> * This will get everything in the list archive in one message.
> * This will inspire me or someone else to distill this all down to
>   a reasonable FAQ entry, and we can get it in the FAQ.
>
> Note: I don't use virtual hosts.  It would be nice if people who do
> help out here.
>
> NOTE: This is a hugh posting!  If you are not interested in virtual
> hosts and don't want to help with the FAQ, please stop reading now
> and delete this message!
>
> > Any Ideas?
>
> How to do this depends on your setup and what effect you want.  Following
are
> some things from past postings to the list, which may or may not help.
>
> ----
>
> Ed Culp once posted:
>
> I can share what I do.  First I don't use realm's in conf/servers.
>
> I have the following in my config/conf.php for virtual domains and
> virtual users.  My ldap structure is similar to yours so hopefully
> it will work for you with minor modification to the three vdomain
> lines assuming that I am understanding your problem which I am not
> particularly good at:-).  I just have cnames for all my vdomains
> and they begin mail.$vdomain.  This also helps my imp/config/conf.php
> file to be exactly the same on my test machine and production
> machine.  So I can change versions on the production machine
> without having to reconfigure.
>
> $conf['hooks']['vinfo'] = 'imp_get_vinfo';
>
> if (!function_exists('imp_get_vinfo')) {
>      function imp_get_vinfo ($type = 'username') {
>          global $conf, $imp;
>
>          $vdomain = $_SERVER['HTTP_HOST'];
>          $vdomain = preg_replace('|^mail\.|i', '', $vdomain);
>          $vdomain = strtolower($vdomain);
>
>
>          if ($type == 'username') {
>              return $imp['user'] . '@' . $vdomain;
>         } elseif ($type == "vdomain") {
>             return $vdomain;
>         } else {
>             return new PEAR_Error('invalid type: ' . $type);
>         }
>     }
> }
>
> ----
>
> Ed Culp followed up with:
>
> I forgot on thing in my previous emailthat may not be obvious,
> my server.php file I only have one defined server that is based
> on the calling url.
>
>
> $vdomain = strtolower(preg_replace('|^mail\.|i', '',
$_SERVER['HTTP_HOST']));
>
> $servers['_prompt'] = array(
>     'name' => 'Choose a mail server:'
> );
>
> $servers['imap'] = array(
>     'name' => $vdomain,
>     'server' => $vdomain,
>     'protocol' => 'imap',
>     'port' => 143,
>     'folders' => 'INBOX.',
>     'namespace' => '',
>     'maildomain' => $vdomain,
>     'smtphost' => $vdomain,
>     'realm' => '',
>     'preferred' => $vdomain
> );
>
> It too is dynamic so I don't have to reconfigure if I copy my test version
> to production.  Unfortunately, all based on a mail.$vdomain but a case
> statement could easily change that:-)
>
> ----
>
> Zhang Bo posted a message, apparently originally from Alejandro Celi
Mariegui,
> which included:
>
> } 3.- I configured the config example sent by Jim in this email:
>
> http://marc.theaimsgroup.com/?l=imp&m=101195869916272&w=2
>
>
> *********************   mail bgain
> *************************************************
>
> Hi everyone,
>
> I recently install Imp3.0 + horde 2.0 on our sun cobalt server, just
modified a
> few line of the codes, and make all webmail hosts pointed to the horde
> directory, now it can serve webmail for all the virtual domains in this
server,
> I found this is very handy for ISPs, here I wanna share my experience with
> everyone, GREAT JOB GUYS!!! I love IMP and looking forward for IMP + Turba
> integrated.
>
> in servers.php:
>
> //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,
>         }
>
> The above script detects the domain name and sets the right server
properties.
>
> another change that i found useful was modify trailer.txt and compose.php
make
> it subs the virtual domain name into the trailer.txt.
> in my trailer.txt:
> --------------------------------------------------------
> This mail sent through MY_WEBMAIL_HOST webmail service
>
> in compose.php at line 674 I add this code:
> $trailer =ereg_replace('MY_WEBMAIL_HOST', substr( getenv('HTTP_HOST'),
> strpos(getenv('HTTP_HOST'), '.') + 1), $trailer);
>
> the above subs. MY_WEBMAIL_HOST with the virtual domain.
>
> hope someone would find this useful.
>
> jim
>
> --------------------------------------------------------
> This mail sent through firstlink.com.au webmail service
>
> ******************** mail end
*********************************************
>
> } looks good!
> }
> } All works fine still now!
> }
> } The problem is:
> }
> } When user "alex" (real user alex_domain1_com) compose and email
> } and send it
> } to another mailserver, it always arrive using the real account user name
> } like this:
> }
> } alex_domain1_com@domain1.com
> }
> } I wish I could have a config or php tip for making that the "From field"
> } changes to the virtual sender like this
> }
> } alex@domain1.com
> }
> } Best Regards,
> }
> } Alex Celi
>
> And this is the solution,
>
> Thanks to the chat people #horde
> In /horde/imp/config/conf.php We put a new function, like this:
>
> $conf['hooks']['from'] = 'imp_set_username';
>
> if (!function_exists('imp_set_username')) {
>         function imp_set_username ($imp)
>         {
>                 return preg_replace("/_.*/", "", $imp['user']);
>         }
> }
>
> And it work fine.
>
> ----
>
> Jon Lewis wrote:
>
> In my setup, I have qmail+vpopmail handling virtual domains.  I installed
> courier imap on the qmail server.  I have IMP running on its own server.
> My goal was to make any domain on the qmail+vpopmail server (or any
> qmail+vpopmail server we happen to setup) able to use IMP without having
> to manually configure anything on the IMP server for each domain.
>
> The first thing I did was a variation on the servers.php code I think was
> originally posted by jimmy@firstlink.com.au.
>
> // Virtual domain handling
>
> //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/notls';
> $this_mail_port=143;
> $this_mail_folder='INBOX.';
> $this_mail_namespace='';
> $this_mail_smtphost='smtp.'.$this_domain;
> $this_mail_realm='';
>
> $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 then setup a imp_get_vinfo function by doing the following in
> imp/config/conf.php:
>
> $conf['hooks']['vinfo'] = 'imp_get_vinfo';
> if (!function_exists('imp_get_vinfo')) {
>     function imp_get_vinfo ($type = 'username') {
>         global $conf, $imp;
>
>         $vdomain = getenv('HTTP_HOST');
>         $vdomain = preg_replace('|^webmail\.|i', '', $vdomain);
>         $vdomain = strtolower($vdomain);
>
>         if ($type == 'username') {
>             return (preg_replace('|@.*|', '', $imp['user']) . '@' .
$vdomain);
>         } elseif ($type == "vdomain") {
>             return $vdomain;
>         } else {
>             return new PEAR_Error('invalid type: ' . $type);
>         }
>     }
> }
>
> Now it turned out the real trick was disabling UseCanonicalName in
> httpd.conf.  This is the setting that will cause apache to generate URL's
> pointing to the wrong host/domain when trying to do a mass virtual hosting
> IMP where everyone has webmail.theirdomain.com pointing to the same A
> record.
>
> With UseCanonicalName off, and the above IMP settings, any domain that has
> a webmail hostname can use IMP providing they have an imap server
> available at mail.theirdomain and that imap server expects logins in the
> format user@theirdomain.  The only configuration needed is setting up the
> domain on the mail server and making a webmail.domain A or CNAME record
> pointing to the IP or hostname of the IMP server.
>
> I did make some small cosmetic changes to compose.php, mostly just to
> alter the IMP added Received: line which would add user@domain...since in
> my case user is already user@domain, it was adding
> user@domain@webmail.domain.  This is also why I have set the realm to ''.
> Initially, I was setting it to webmail.$this_domain, but that resulted in
> prefs and turba objects being owned by user@domain@webmail.domain...not
> really a problem, but kind of messy looking.
>
> With the above imp_get_vinfo function, users are supposed to log in as
> just user and imp displays the @theirdomain to the right of the username
> box...but if they mess up and log in as user@domain (you know they
> will...I even did it several times out of habit) it'll strip off
> everything right of and including the @ and build their username based on
> the URL they used to get to IMP.
>
> Incidentally, there is a bug in the latest stable release of vpopmail that
> causes authentication failures with courier's authdaemond.  This can be
> solved by upgrading vpopmail to the latest development version (I wasn't
> interested in that) or by doing some very minor hacking in authdaemond to
> work around the vpopmail bug.  Contact me off-list if you want more info
> on the workaround.
>
> For security reasons, I highly recommend limiting which imap servers your
> virtual hosting IMP is willing to talk to.  Otherwise, people could use
> your IMP unexpectedly, or worse, spam through it.  I'm using ipchains on
> the IMP server to limit outgoing connections to port 143 to only
> authorized mail servers.
>
> ----
>
> and followed up with:
> I forgot to add in my message last night, that for the apache config, I've
> setup a VirtualHost with a dummy name (though it must resolve) and in that
> VirtualHost, I have
>
> ServerAlias webmail.*
>
> This allows that VirtualHost entry to match any webmail.* that's pointed
> at the IP for the dummy name.
>
> ----
>
> Well, that's all.
>
> --
> Eric Rostetter
> The Department of Physics
> The University of Texas at Austin
>
> "Can you hear me now? ... Good!"
> "Can you hear me now? ... Good!"
>