Third Party Contributions > Old Style Plug-Ins

Multiple Domains Login

(1/12) > >>

coolant:
I just downloaded RoundCube, and I love it so far. I host over 50 domains and people hated typing in their full email addresses to login. This will only work if you have mail.domain.com, mail.domain2.com, etc. I quickly made a solution.



Before you start, make backups.

index.php

Under if ($_action=='login' && $_task=='mail'){ add :

--- Code: ---$user = "$_POST[_user]@" . substr($_SERVER[HTTP_HOST], 5) . "";
--- End code ---

And then change :

--- Code: ---else if (isset($_POST['_user']) && isset($_POST['_pass']) && rcmail_login($_POST['_user'], $_POST['_pass'], $host))
--- End code ---

to


--- Code: ---else if (isset($user) && isset($_POST['_pass']) && rcmail_login($user, $_POST['_pass'], $host))
--- End code ---

That takes care of the actually logging in part. Now to change the form.

program/include/main.inc

Find function rcmail_login_form($attrib)

Change


--- Code: ---$input_user = new textfield(array('name' => '_user', 'size' => 30));
--- End code ---
to
--- Code: ---$input_user = new textfield(array('name' => '_user', 'size' => 15));
--- End code ---

Change


--- Code: ---$fields['user'] = $input_user->show($_POST['_user']);
--- End code ---
to
--- Code: --- $fields['user'] = "" . $input_user->show($_POST['_user']) . " @ " . substr($_SERVER[HTTP_HOST], 5) . "";
--- End code ---

I know I could of done it 50 different ways, but this way was easy and quick.

Good luck!

bpat1434:
Easier than properly configuring the main.inc.php file?

// the mail host chosen to perform the log-in
// leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL connection, enter ssl://hostname:993
$rcmail_config['default_host'] = array('imap.domain.net' => 'Domain', 
'imap.domain2.net' => 'Domain 2'
);

// TCP port used for IMAP connections
$rcmail_config['default_port'] = 143;

// 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 hosts
$rcmail_config['username_domain'] = array('imap.domain.net' => 'domain.net',
 'imap.domain2.net' => 'domain2.net'
 );

// This domain will be used to form e-mail addresses of new users
// Specify an array with 'host' => 'domain' values to support multiple hosts
$rcmail_config['mail_domain'] = array('imap.domain.net' => 'domain.net',
 'imap.domain2.net' => 'domain2.net'
);

Hmm... me thinks not....

Heck... you can take it one step further in ease:

// the mail host chosen to perform the log-in
// leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL connection, enter ssl://hostname:993
$rcmail_config['default_host'] = array('imap.domain.net' => 'Domain', 
'imap.domain2.net' => 'Domain 2'
);

// TCP port used for IMAP connections
$rcmail_config['default_port'] = 143;

// 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 hosts
$rcmail_config['username_domain'] = array('imap.domain.net' => 'domain.net',
 'imap.domain2.net' => 'domain2.net'
 );

// This domain will be used to form e-mail addresses of new users
// Specify an array with 'host' => 'domain' values to support multiple hosts
$rcmail_config['mail_domain'] = $rcmail_config['username_domain'];

flosoft:
thx for both tutorials :D

SKaero:
Its good code, But I only have one domain 8)

tenaka:
ok guys, the second solution sounds great but its not really useful.

all my customers also use: mail.domain1.com mail.domain2.com etc...

that means I do not want them to see a dropdown of all the domains I host (in coolants example it would be a dropdown list of 50 domains) and chose theirs from the list, instead roundcube should be able to detect the domain where the user logged in from, strip mail. from it and append it to the username, at least thats what some plugins for squirrelmail can do...

Navigation

[0] Message Index

[#] Next page

Go to full version