Author Topic: Multiple Domains Login  (Read 107718 times)

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Multiple Domains Login
« Reply #45 on: January 05, 2008, 12:13:48 PM »
Fantastic!! Glad to hear you got it working as you wanted ;)
 
  

Offline dano

  • Full Member
  • ***
  • Posts: 124
Re: Multiple Domains Login
« Reply #46 on: January 11, 2008, 12:10:29 PM »
Hello,

I use part of a hack that was originally posted as a Cpanel password change hack. I will try to post the pertinent information here. I am using this on a Cpanel 11 server with multiple virtual hosts and multiple users per domain.

I have my httpd.conf configure so that Roundcube loads when a user browses to http://www.domain.com/rcmail.

The user MUST put 'www' in the url or else it will not work. An error returns and Roundcube puts the user name in the log in box but you can see that it's incorrect.

In index.php locate the login section (find // try to log in). Replace it with
Code: [Select]
// try to log in
if(isset($_POST['_user']) && $_action == 'login' && $_task == 'mail')
 {
 if($_SERVER['SERVER_NAME'] and !preg_match('/(.*)\@(.*)/',$_POST['_user'])){
    $domain = preg_replace('/^(\w*)\./','',$_SERVER['SERVER_NAME']);
    $_POST['_user'] = $_POST['_user']."@".$domain;
 }

In main.inc.php:

Set default_host to localhost
Code: [Select]
$rcmail_config['default_host'] = 'localhost';

Set smtp_server to localhost
Code: [Select]
$rcmail_config['smtp_server'] = 'localhost';

Set smtp_user to %u
Code: [Select]
$rcmail_config['smtp_user'] = '%u';

Set smtp_pass to %p
Code: [Select]
$rcmail_config['smtp_pass'] = '%p';

And I believe that that is everything. Hope that's able to help someone!

Offline yenemy

  • Newbie
  • *
  • Posts: 2
Re: Multiple Domains Login
« Reply #47 on: March 27, 2008, 11:49:09 AM »
Edit: Haha, sorry about the post resurrection; didn't notice this was from way back in January

Hi all, just installed Roundcube a few days ago and I'm liking it quite a lot. I too got tired of typing in my full email address when logging in, so I put the following in main.inc.php:

Code: [Select]
// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple host
$hostStr = $_SERVER['HTTP_HOST'];
$wPos = strPos($hostStr, '.')+1;
$rcmail_config['username_domain'] = substr($hostStr,$wPos);

Basically just grabs the browser domain and strips the first element. So as long as the user's logging in at the right domain, they should be fine. Works a treat for me, thought I'd share in case anyone else wants it. I saw some stuff with database calls, etc. earlier in this thread, but that's way beyond me at this point... I'm no programmer, and certainly not a PHP one.

Offline cornbread

  • Newbie
  • *
  • Posts: 5
Re: Multiple Domains Login
« Reply #48 on: March 27, 2008, 12:33:03 PM »
Hope you don't mind I added this to the trac as a feature request.

http://trac.roundcube.net/ticket/1484930

Offline yenemy

  • Newbie
  • *
  • Posts: 2
Re: Multiple Domains Login
« Reply #49 on: March 27, 2008, 03:48:17 PM »
cornbread, I don't mind at all!
Although, a more foolproof way would be to grab the last two elements instead of stripping the first one since some subdomains come in differently: e.g., four elements like some subdomains ("http://www.email.domain.com")

---------------------------------

So after my last post, I figured I should just go ahead and do it.

And here it is:

Code: [Select]
// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple host

$hostArr = explode('.',$_SERVER['HTTP_HOST']);
$hostDomain = join('.',array_reverse(array(array_pop($hostArr),array_pop($hostArr))));
$rcmail_config['username_domain'] = $hostDomain;

--------------

Haha, which looks a lot like a dupe of jingo's.

Offline wheaties82

  • Jr. Member
  • **
  • Posts: 11
Roundcube and multiple domains
« Reply #50 on: December 10, 2008, 09:29:25 PM »
First off I am a noob to this so go gentle on me . . . I am experiencing a strange issue with Roundcube 0.2-beta.

I have an email server that has two virtual domains and Postfix is configured to accept mail for either domainA or domainB. so johndoe@domainA can also be johndoe@domainB -- same email (aka johndoe can log into domainA or domainB and see the same Maildir files) just different mail servers are used for sending / receiving.

I have installed RC for domainA already with its own independent database and user. It is functioning properly.

In a separate folder with a new installation (independent directory from domainA) I have another installation referencing a (new) seperate database and user. The installation summary ends without an issue -- everything says it is ok, I can even send a test email. The strange issue is when I attempt to do a test login (or normal login) I get a timeout error. Below are examples:

[08-Dec-2008 23:02:50] PHP Fatal error: Maximum execution time of 120 seconds exceeded in /var/www/domainB/webmail/program/lib/imap.inc on line 317
[08-Dec-2008 23:08:23] PHP Fatal error: Maximum execution time of 120 seconds exceeded in /var/www/domainB/webmail/program/lib/imap.inc on line 208

I have verified that domainB is working with IMAP as I can login to the account via thunderbird and send and receive without any problems.  I have verified that all my MX and DNS records are correct -- as I can send and receive email no problem

I have tried sharing the same database as domainA but I get the same results -- a timeout and error referrencing imap.inc

I have read the posts included in this thread but they all seem to point to solutions where the user has to enter '@domainA' after the username -- and my server is not configured to do that -- it only needs the username.

Am I incorrect in assuming that Roundcube is capable of having two independent installations referencing different domains on the same server?

:confused::confused::confused:

Offline zhylninc

  • Newbie
  • *
  • Posts: 8
Multiple Domains Login
« Reply #51 on: April 25, 2010, 02:31:09 AM »
and nginx config
 location / {
            proxy_pass http://192.168.1.2/;
            proxy_set_header Host $host;
                       }


proxy_set_header Host $host;
;)

Offline egrogg

  • Jr. Member
  • **
  • Posts: 12
Multiple Domains
« Reply #52 on: June 04, 2011, 07:28:38 PM »
Quote from: Mickey;7794
I'll just add my 2 cents here. This works fine for us with multiple domains:
we have mail.***.com domains pointing to one rc install. This hack works
like: if the domain has a prefix "mail" then it get's rid of the server part and
@domain part in login. if no "mail" prefix found it displays the standard login
form where you have to type in everything:

in config/main.inc.php add this:
Code: [Select]
function getDomain() {
$host=$_SERVER['HTTP_HOST'];
$prefix='mail';
$arr=explode('.',$host);
if ($arr[0]==$prefix) { unset($arr[0]); $host=implode('.',$arr); }
else { $host=''; }
return $host;
}


and modify the following 2 config lines:
Code: [Select]
$rcmail_config['default_host'] = getDomain();
Code: [Select]
$rcmail_config['username_domain'] = getDomain();

Hope this is helps for someone,
Mickey



This solution works great!  Perfect instructions!

is there a way to change the logo and the "Welcome to *** webmail"  per domain?

I have them going to wmail.domain1.com and wmail.domain2.com

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Multiple Domains Login
« Reply #53 on: June 04, 2011, 11:34:08 PM »
Do the same thing for $rcmail_config['product_name'].

Offline egrogg

  • Jr. Member
  • **
  • Posts: 12
Multiple Domains
« Reply #54 on: June 05, 2011, 08:19:07 AM »
Ahh..I C...

I am guessing here but maybe for the logo there would need to be some kind of "if" statement?  I am not a programmer so, maybe if someone would know how to do that, it would be great...

Offline egyreal

  • Newbie
  • *
  • Posts: 1
    • http://www.egyreal.com
Multiple Domains Login
« Reply #55 on: June 12, 2011, 08:15:50 AM »
thanks dano

Offline saulos

  • Newbie
  • *
  • Posts: 5
Re: Multiple Domains Login
« Reply #56 on: August 16, 2016, 01:11:10 PM »
Hi, sorry to reopen an old post.
But I will like to know if the solution exposed here are still valid or now we have a different solution ?
Just to be clear I have 2 domain and I will like to have the domain added to the username like :
jim --> jim@domain1.com

if jum chose the 'domain1.com' from the dropdown-

Thanks