Configuring roundcube with SSL for SMTP and IMAP

I have tried setting up SMTP and IMAP with a variety of settings and am unable to get anything working on my server. I have an SSL certificate on the server and can connect to it through https fine.

When I run round cubes auto configurator and test the configuration at the end, IMAP works and can log in but when I try and log into the account via "mydomain/roundcubemail", it does not work. (Pictures Below)

In configuration IMAP working in configuration

In mydomain/roundcubemail I get this error With the error: IMAP log error: IMAP Error in /usr/share/roundcubemail/program/lib/Roundcube/rcube_imap.php (184): Login failed for [email protected] from 193.61.254.32. AUTHENTICATE PLAIN: Authentication failed.

Furthermore, SMTP is failing to work with a NOT OKAY message. enter image description here

And this is the configuration that I am using

$config['db_dsnw'] = 'mysql://roundcube:MYPASSWORD@localhost/roundcube';

$config['debug_level'] = 5;

$config['sql_debug'] = true;

$config['imap_debug'] = true;

$config['ldap_debug'] = true;

$config['smtp_debug'] = true;

$config['default_host'] = array('localhost:143', 'domain:143', 'ssl://domain:993');

$config['default_port'] = 993;

$config['smtp_server'] = 'ssl://domain';

$config['smtp_port'] = 465;

$config['smtp_user'] = '%u';

$config['smtp_pass'] = '%p';

$config['support_url'] = 'http://domain';

$config['des_key'] = 'myKey';

$config['username_domain'] = 'domain';

$config['product_name'] = 'Mail | domain';

$config['plugins'] = array();

$config['language'] = 'en_US';

$config['spellcheck_engine'] = 'pspell';

$config['draft_autosave'] = 60;

Any suggestions?


I know this question is old but can be useful for someone.

In order to get IMAP running with SSL or TLS, you must copy IMAP configuration from config/defaults.inc.php file to config.inc.php. And prefix your server address with ssl:// or tls:// depending upon your server configuration.
For example: $config['default_host'] = 'ssl://imap.yourserver.tld';

//To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
$config['default_host'] = 'imap.yourserver.tld'; //your imap server address
$config['default_port'] = 143; //You must define the same port as your server
// IMAP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or null to use
// best server supported one)
$config['imap_auth_type'] = 'LOGIN'; //You must define a authorization type 

I'm going to presume the configuration file you posted is the one you use. It seems strange that you have domain written in there so many times, but I will answer like the file is written like that.

That means that in most places you should substitute domain for what ever domain you are acutally using - in my examples it will be example.dom.

So to set up IMAP with secure sockets in roundcube, you need to change

$config['default_host'] = array('localhost:143', 'domain:143', 'ssl://domain:993');

to

$config['default_host'] = 'ssl://example.dom';

But in the case you are hosting your webmail on the same domain you are setting up mail for, consider using the %n (for the hostname) or %t (for the stripped hostname domain) replacement variables.

The same is true for SMTP:

$config['smtp_server'] = 'ssl://domain';

should change to

$config['smtp_server'] = 'ssl://example.dom';

or, if appropriate, to something containing %n or %t.

This all, of course, presumes there is a TLS IMAP server (such as dovecot) running on example.dom:993, and a TLS SMTP server (such as OpenSMTPD) on example.dom:465, and that those ports have been opened.