Author Topic: Auto Determine Host From E-mail Address  (Read 7084 times)

Offline tealnet

  • Newbie
  • *
  • Posts: 4
Auto Determine Host From E-mail Address
« on: December 30, 2006, 07:51:12 PM »
Since we host multiple domains, it would be nice to have an option for the host to automatically determined from the e-mail address so users don't have to type it in. For example, if the username entered is  bob@mydomain.com, the host could automatically be set to  mail.mydomain.com

Would anyone else find this to be helpful?

Offline dgec

  • Jr. Member
  • **
  • Posts: 10
Re: Auto Determine Host From E-mail Address
« Reply #1 on: February 05, 2007, 05:55:04 PM »
Absolutely!

Offline Insanity5902

  • Newbie
  • *
  • Posts: 3
Re: Auto Determine Host From E-mail Address
« Reply #2 on: February 05, 2007, 06:06:35 PM »
If you ran the webmail from a different server as the mail server, then yes, this would be very useful.

I currently just run a single mail server, and run the webmail on it.

Take a look here. There are several people working on something similar, to grab the domain information form the http address and add it to the user name.

I like my solution the best, of course :), where I grab the header information, through it into an array, separated by periods, reverse it, then the array[0] is your tld (com, org, etc), array[1] is your next level of domain, etc.

You can grab this and then put it in the defualt host field, a crude code would be something like this

$tempDomain array_reverse(explode(".",$_SERVER['HTTP_HOST']));
$rcmail_config['default_host'] = 'ssl://mail' $tempDomain[1'.' $tempDomain[0] . ':993';


That is almost the exact code I use to grab the username_domain

Offline dgec

  • Jr. Member
  • **
  • Posts: 10
Re: Auto Determine Host From E-mail Address
« Reply #3 on: February 05, 2007, 06:12:26 PM »
I'm posting a further question on the other thread you mention.

Offline com2

  • Newbie
  • *
  • Posts: 4
Re: Auto Determine Host From E-mail Address
« Reply #4 on: August 28, 2019, 04:12:01 PM »
Best would be when there is one roundcube for all servers for easy maintenance and one company link. My idea would be to add another variable or improve the behaviour of variable %s :

Quote
domain name after the '@' is used to do a dns mx look up. When there is only one mx, than that will be used. When there are more, then they will be listed in an array so the user can choose.


This will cover most cases just fine and can be easily accomplished with something like this:

Code: [Select]
<?php
if (getmxrr("gmail.com",$mxhosts)) {
  if (
count($mxhosts) == 1) {
    
$output $mxhosts[0];
  } else {
    foreach( 
$mxhosts as $mxhost) {
      
$output[$mxhost] = $mxhost;
    }
  }
  print(
"<pre>");
  
print_r($output);
  print(
"</pre>");
}

« Last Edit: August 28, 2019, 04:16:11 PM by com2 »