Roundcube Community Forum

 

Multiple Domains Login

Started by coolant, July 25, 2006, 11:13:01 PM

Previous topic - Next topic

bpat1434

Fantastic!! Glad to hear you got it working as you wanted ;)
 
 

dano

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
// 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
$rcmail_config['default_host'] = 'localhost';

Set smtp_server to localhost
$rcmail_config['smtp_server'] = 'localhost';

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

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

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

yenemy

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:

// 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.

cornbread

Hope you don't mind I added this to the trac as a feature request.

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

yenemy

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 ("//www.email.domain.com")

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

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

And here it is:

// 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.

wheaties82

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:

zhylninc

and nginx config
 location / {
            proxy_pass http://192.168.1.2/;
            proxy_set_header Host $host;
                       }


proxy_set_header Host $host;
;)

egrogg

Quote from: Mickey;7794I'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:
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:
$rcmail_config['default_host'] = getDomain();
$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

SKaero

Do the same thing for $rcmail_config['product_name'].

egrogg

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...

egyreal


saulos

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

Dwel

#57
Quote from: saulos on August 16, 2016, 01:11:10 PMHi, sorry to reopen an old post.

Me too, But there doesnt seem to be a clear answer. Seams my hosts dir structure puts all of non primary domains inside the publc_html folder of the root domain. Which doesnt seem like it should be the norm. I made a symlink to the roundcube install and it has only worked flawlessly. As far as users typing out there full address, I could care less at this point. Its typing not lifting. Although I am trying a few of these antiquated solutions.