Author Topic: Need to have user%domain.tld as login with username_domain support  (Read 2726 times)

Offline Ultan44

  • Newbie
  • *
  • Posts: 2
My old email host was simple, you just stick the "user" part in the box and the username_domain config adds "@domain.tld" before trying to log in to the imap/smtp servers.
My new host has an absurd format of "user%domain.tld", I can't seem to configure Roundcube to do this, any username formatting seems to add an "@" symbol where I want a "%".

Is it possible?

Thanks

Offline Ultan44

  • Newbie
  • *
  • Posts: 2
Re: Need to have user%domain.tld as login with username_domain support
« Reply #1 on: January 22, 2016, 05:16:53 PM »
I've managed to resolve this with a plugin but simpler ideas (or code corrections) are welcome!

I decided not to hook into user_create as I would prefer to keep the "user@domain.tld" format in the UI.

Code: [Select]
class percent_authentication extends rcube_plugin
{
public $task = 'login|mail';
private $rc;

function init()
{
$this->rc = rcube::get_instance();
$this->add_hook('authenticate', array($this, 'authentication'));
$this->add_hook('smtp_connect', array($this, 'smtp_connection'));
}

function authentication($args)
{
return array('user' => str_replace('@', '%', $args['user']));
}

function smtp_connection($args)
{
return array('smtp_user' => str_replace('@', '%', $this->rc->user->get_username()));
}
}