Author Topic: Automatically figuring out host with email login???  (Read 15696 times)

Offline blove57

  • Jr. Member
  • **
  • Posts: 18
Automatically figuring out host with email login???
« on: November 05, 2007, 01:38:50 AM »
I have users from many different domains logging into Roundcube webmail. Because of this I left this blank in main.inc.php:
$rcmail_config['default_host'] = '';

The problem is users find this really confusing when they have an emails address, password and host to fill out during the log in page. What I'd like to do is get the domain from the email loggin and place is in the $rcmail_config['default_host'] value. So for example, when someone logs in as john@fundomain.com, the host should automatically be valued at fundomain.com.

In the wiki it says:
// 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
// $serverut = $_SERVER['SERVER_NAME']; <<< get the server name example http://www.site.com
// $wsrt = 'http://www.'; <<< string to replace
// $serverput = str_replace($wsrt,'',$serverut); <<< replace the host address deleting the www in this case
// $rcmail_config['username_domain'] = $serverput; <<< and the var is ready!

The problem with this is that SERVER_NAME is already figured out before the users fills it their information. I want to fill the host value after the user has filled their information. How would I implement this?

Offline OJM

  • Newbie
  • *
  • Posts: 3
Re: Automatically figuring out host with email login???
« Reply #1 on: November 21, 2007, 08:58:26 AM »
This is exactly what I'd like to achieve aswell.

Off the top of my head, the SMTP user authentication uses '%u' as the username of the account. Would it be possible to find out how this is being set, and add another function to strip off the @ sign and everything before? You could then use this new 'function' to pass through as the host name...?

Offline blove57

  • Jr. Member
  • **
  • Posts: 18
Re: Automatically figuring out host with email login???
« Reply #2 on: November 26, 2007, 03:59:25 PM »
I'm also trying to tackle this. The RoundCube code doesn't really seem to be coded for change. What I was going to do is hack the login page with Javascript. All I need to do is add an onsubmit to the form in roundcube\program\include\rcmail_template.inc. I was going to add it in this line "$form_start = !strlen($attrib['form']) ? '' : '';", but that just creates a 2nd form if I mess with the conditions.

To get the domain from the email address, this is the formula I was going to use:
document.getElementById('rcmloginuser').value.substring(document.getElementById('rcmloginuser').value.substring(0,document.getElementById('rcmloginuser').value.lastIndexOf('@')+1).length,document.getElementById('rcmloginuser').value.length+1)

So all I have to do in the form is this (notice just the onsubmit):


Then I can make the 'rcmloginhost' input hidden. I'm getting closer but really need help from a RoundCube coder or guru. Any ideas?

Offline OhYa

  • Newbie
  • *
  • Posts: 5
Re: Automatically figuring out host with email login???
« Reply #3 on: March 12, 2008, 09:06:46 PM »
I need to do this as well...
Anyone have any updates on this?

Exactly what I need to do is this,
I have several domains with a few users on each.
So I need them to be able to login to a single webmail.MyMainDomain.com

Thanks

Offline sebastian

  • Newbie
  • *
  • Posts: 2
Re: Automatically figuring out host with email login???
« Reply #4 on: April 08, 2008, 12:27:43 PM »
Looking also for this feature ... but I need to configure different mail-servers according to the login.

Like user1@domain1.com uses domain1-mail.somedomain.com; user2@domain2.com uses domain2-mail.somedomain.com, etc.

Looking forward to such feature :-)

Offline Eamorr

  • Newbie
  • *
  • Posts: 1
Automatically figuring out host with email login???
« Reply #5 on: February 11, 2009, 01:04:09 PM »
Quote from: sebastian;11414
Looking also for this feature ... but I need to configure different mail-servers according to the login.

Like user1@domain1.com uses domain1-mail.somedomain.com; user2@domain2.com uses domain2-mail.somedomain.com, etc.

Looking forward to such feature :-)


It's tricky hacking the roundcube code -- all the localization and security features (session variables being cleare/cookies being cleared) makes life very difficult.

I spent an afternoon hacking what I thought would be an easy-enough job. I've given up!

I've 10 domains -- I'd like the 'domain' textfield to be auto-completed and hidden. All I want visible to the user is the fields 'username' and 'password'. Roundcube is accessed via: webmail.xxxx.com for each of the 10 domains...

Hope someone can provide a nice solution,

Offline pesz1

  • Newbie
  • *
  • Posts: 1
Automatically figuring out host with email login???
« Reply #6 on: March 14, 2010, 09:18:01 PM »
This is an old thread but below is my workaround:

$rcmail_config['default_host'] = str_replace("www.","",$_SERVER['SERVER_NAME']);

I had to use str_replace b/c if the user typed http://www.domain.com/roundmail it would append that to their email address like user@www.domain.com.

Offline netbit

  • Newbie
  • *
  • Posts: 3
Automatically figuring out host with email login???
« Reply #7 on: April 27, 2011, 04:52:02 AM »
Quote from: blove57;9191
... when someone logs in as john@fundomain.com, the host should automatically be valued at fundomain.com...

... I want to fill the host value after the user has filled their information. How would I implement this?


This was implemented on changeset 4705 (Changeset 4705 ? Roundcube Webmail) and will be available on the next public release.

--
Victor Benincasa