Author Topic: Roundcube client cannot connect to postfix mail server  (Read 6972 times)

Offline azizgstest

  • Newbie
  • *
  • Posts: 3
Roundcube client cannot connect to postfix mail server
« on: July 20, 2018, 12:42:03 PM »
Hi RC users,


I installed roundcube with postfix, but I'm unable to access it, it's giving an error message "connexion to storage server error", however I'm able to connect to my postfix server using outlook.

my roundcube config file contains the following values :

$config['db_dsnw'] = 'mysql://user:mypassword@localhost/mydatabase';
$config['default_host'] = 'ssl://localhost';
$config['default_port'] = 993;


$config['smtp_server'] = 'tls://localhost';
$config['smtp_port'] = 587;

In the logs I found the following error :


Login failed for user1@mycompany.com from 66.162.222.19. Could not connect to ssl://localhost:993: Unknown reason in /var/www/mail/roundcubemail/program/lib/Roundcube/rcube_imap.php on line 196 (POST /roundcubemail/?_task=login&_action=login)



BR

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Roundcube client cannot connect to postfix mail server
« Reply #1 on: July 21, 2018, 03:39:46 AM »
When using localhost SSL/TLS is not required since no data is transmitted. So you could change your config to:

$config['default_host'] = 'localhost';
$config['default_port'] = 143;
$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 25;

The "Unknown reason" error is likely coming from the fact that OpenSSL cannot verify your cert. There can be a few resons for that: is the CN on your cert localhost? is your cert a self signed one, or from a publisher that OpenSSL does not recognise like LetsEncrypt?

If you really want to use SSL/TLS you should change "localhost" to the public address of your IMAP + SMTP servers. The one that matches the CN on your cert. If you are using a self signed cert you will need to confiugre $config['imap_conn_options'] and $config['smtp_conn_options'] to either disable peer verification or tell OpenSSL how to verify the cert.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline azizgstest

  • Newbie
  • *
  • Posts: 3
Re: Roundcube client cannot connect to postfix mail server
« Reply #2 on: July 25, 2018, 02:07:48 PM »
Hi John,

Thank you for your feedback, in fact changing the following resolves my issue :

$config['default_host'] = 'localhost';
$config['default_port'] = 143;
$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 25;

And yes, I'm using a certificate signed by known authority, the CN is my domain name. 
However, since I need to use TLS/SASL for sending/receiving emails, I'm wondering if it's possible to use SMTP, IMAP without encryption for roundcube (anything coming from localhost), and for any in/out external emails, they will be encrypted ?

Thank you
 

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Roundcube client cannot connect to postfix mail server
« Reply #3 on: July 26, 2018, 02:45:09 AM »
Quote
However, since I need to use TLS/SASL for sending/receiving emails, I'm wondering if it's possible to use SMTP, IMAP without encryption for roundcube (anything coming from localhost), and for any in/out external emails, they will be encrypted ?
These are 2 separate things. how one client communicates with a server and how that server communicates with other clients/servers is not related to each other. What you describe is certainly possible, and I think quite normal. Its usually possible to configure the IMAP and SMTP server to require external clients to use encryption when localhost does not.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline azizgstest

  • Newbie
  • *
  • Posts: 3
Re: Roundcube client cannot connect to postfix mail server
« Reply #4 on: July 26, 2018, 07:25:45 AM »
Hello,


I tried to use both TLS and plaintext authentication methods in my postfix server, with the idea to block external SMTP/IMAP traffic using the firewall, and got the following results :

Incoming emails are working. but I'm not able to send emails from roundcube the error is the following :

Authentication failure: SMTP server does not support authentication (Code: ) in /var/www/mail/roundcubemail/program/lib/Roundcube/rcube.php on line 1667 (POST /?_task=mail&_unlock=loading1532603967783&_lang=fr_FR&_framed=1&_action=send

My config file is :


// IMAP
$config['default_host'] = 'localhost';
$config['default_port'] = 143;
$config['imap_auth_type'] = 'LOGIN';
$config['imap_delimiter'] = '/';

// SMTP
$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 25;
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['smtp_auth_type'] = 'LOGIN';



Any hints what can cause this issue ?

Thanks in advance.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Roundcube client cannot connect to postfix mail server
« Reply #5 on: July 26, 2018, 08:25:04 AM »
if you smtp server does not support authentication then you should set

Code: [Select]
$config['smtp_user'] = '';
$config['smtp_pass'] = '';
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…