7

Currently, we have a fully working POP/IMAP/Webmail system (using Dovecot and Roundcube) that is a gleaming tower of perfection in its intended design. We have thousands of customers who belong to a "default" domain (I'll call it ourdomain.com), and successfully log in with a username and password. We have a few thousand more who own domains that we host, and they log in successfully with their full e-mail address and password (call it customerdomain.com). It's been this way since the 1990s, with a lot of entrenched customer configuration.

The problem is now that people are used to logging into web forms with a full e-mail address, people who use ourdomain.com have to be reminded to log into webmail using only their username. This is a call our tech support department gets several times a week (and even I am guilty of doing this, I just don't call tech support about it), and probably should be eliminated with some kind of software solution.

So how do we get either Roundcube or Dovecot to recognise "username@ourdomain.com" as "username" instead, without having to change everyone's actual username in our system? But only do that if the domain is "ourdomain.com" and not "customerdomain.com". Keep in mind that any custom coding we do will have to be re-implemented every time we do security upgrades, and we would only consider that option as the last possible choice.

TL;DR:

We need this logic:

if $email contains @ourdomain.com
{
    remove @ourdomain.com;
    submit to roundcube;
} else {
    submit to roundcube;
}
Ernie
  • 5,324
  • 6
  • 30
  • 37
  • Yup. Solution is there too. – Andrew Schulman Nov 25 '14 at 20:20
  • 2
    No, it's not a dupe. I saw that question before I asked this one. It's actually the reverse situation. Logging in with just the username part of the e-mail address is not a problem - if the user@ourdomain.com address exists. If it's user@hosteddomain.com, then they need to use the full e-mail address. Customers should be able to log in with **either** Username = user or Username = user@ourdomain.com. – Ernie Nov 25 '14 at 22:20

2 Answers2

5

This problem can be tackled either in roundcube, dovecot or your username-backend.

  1. Roundcube has option to auto append domain parts if no domain provided (as proposed by Kondybas). But it won't too useful in your case. Of course you can patch roundcube (with PHP language) to adding your logic.

  2. Dovecot has option to strip domain (as proposed in Dovecot user lookup fails when using username@domain format) but it can't do conditional stripping (e.g. strip domain if domain = @ourdomain.com). Of course you can patch dovecot (with C language) to adding your logic.

  3. Username-backend is also option too. You don't give the backend you use (either SQL, LDAP, custom engine). I can imagine that you have username column that have two format with and without domain. Now, you can convert all username without domain become username@ourdomain. You can combine this process with option 1 (roundcube auto append domain) so either username and username@ourdomain can login.

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
  • 1
    Option number three is one that I had never considered before, thank you. Modifying software to suit our needs could technically be an option too, but the need for frequent security updates makes that kind of thing a huge pain in the butt. Adding users with the same mailbox is a far more graceful solution. – Ernie Nov 27 '14 at 17:11
3

RoundCube have an option called username_domain

// 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
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['username_domain'] = '';

If you have used subdirectory (like ourdomain.tld/roundcube) set this option to the

$config['username_domain'] = '%n';

If you have used subdomains (like mail.domain.tld) set this option to the

$config['username_domain'] = '%t';

When user provide his full email as login, that email will be used without any changes. If domain part is omitted, RoundCube will use the URL-domain for completion. Also there is number of neat options in the roundcube's config.

Kondybas
  • 6,864
  • 2
  • 19
  • 24
  • 1
    No, this is backwards. Customers who use our domain do *not* include the @ourdomain.com part, they just log in with "myuser". Customers with virtual domain hosting include their full e-mail address. – Ernie Nov 25 '14 at 22:15