Roundcube Community Forum

 

Need to have user%domain.tld as login with username_domain support

Started by Ultan44, January 22, 2016, 03:05:40 PM

Previous topic - Next topic

Ultan44

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

Ultan44

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 "[email protected]" format in the UI.

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()));
}
}