Author Topic: Using Roundcube on an external IMAP Server (strange IMAP usernames)  (Read 5262 times)

Offline Koppolo

  • Newbie
  • *
  • Posts: 2
Hello community,
i'd like to setup an Rouncube to give my users easier access to my hosters IMAP-Mailserver.
I found some tutorials that show how to configure Roundcube to connect to an external Server and it works. So far so good.
My problem is, that my hoster has a stange naming scheme for his IMAP accounts.

For mail address mymail@example.com the imap username is as follows: 33440055-33-0-mymail
asecondaddress@example.com has 33440055-33-0-asecondaddress as username.

Roundcube perfectly works with "33440055-33-0-mymail : password" but my users cannot memorize their usernames.

Is there a way to have easier to memorize usernames in roundcube und roundcube does some kind of translation for the IMAP access?
In fact "33440055-33-0-" must be put as prefix in front of every user name.
How can I achieve this behavior?

Thanks for your support!
Koppolo

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Using Roundcube on an external IMAP Server (strange IMAP usernames)
« Reply #1 on: July 20, 2017, 12:12:11 PM »
A simple plugin could add the prefix. Something like this:
Code: [Select]
<?php
class addusernameprefix extends rcube_plugin
{
  public 
$task 'login';
  
  function 
init()
  {
    
$this->add_hook('authenticate', array($this'authenticate'));
  }
  
  function 
authenticate($args)
  {
    
$args['user'] = '33440055-33-0-'$args['user'];

    return 
$args;
  }
}


Offline Koppolo

  • Newbie
  • *
  • Posts: 2
Re: Using Roundcube on an external IMAP Server (strange IMAP usernames)
« Reply #2 on: July 21, 2017, 12:39:37 AM »
Thanks for your quick reply!  :)
This shoud fix my problem. I'll try to implement this on monday.

But I totally forgot one special case:

There are some users with more than one mail address (mails are aggregated to one mailbox) and their imap username was set with their first activated address.
for example facilitymanagement-munich-2@example.org (first address) and john.doe@example.com (second address) lead to 33440055-33-0-facilitymanagement-munich-2 and your solution would make facilitymanagement-munich-2 out of it and so on...
Our hoster accepts all valid mail addresses als username in his (very ugly and outdated) webmailer. So John Doe was used to login as john.doe@example.com. I think john.doe would be ok too, but facilitymanagement-munich-2 is not 'optimal'. There are also a few persons who changed their surnames due to a marriage. Now they would have to use their old name again. To prevent this we would have to delete and recreate every affected account. Unfortunately there is no other way to change the imap username.  :(

Is there any simple supported suitable solution for individual 'username translation'? If not, I have to go the hard way (backup-delete-recreate-restore a lot of accounts).
« Last Edit: July 21, 2017, 12:50:35 AM by Koppolo »

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Using Roundcube on an external IMAP Server (strange IMAP usernames)
« Reply #3 on: July 21, 2017, 01:58:21 AM »
If you know all of the usernames you could use the virtuser_query plugin that comes with Roundcube to have a database look to translate john.doe@example.com => facilitymanagement-munich-2@example.org