Roundcube Community Forum

 

SMTP Authentication failed

Started by pschmehl, June 15, 2024, 03:36:08 PM

Previous topic - Next topic

pschmehl

I"m brand new to roundcube and trying to sort out problems. I've gotten to the point where I can login and read and handle email (delete, etc.) but I cannot send mail. When I click on Send I get SMTP Error (): Authentication faield.

This is what I have in the config file for smtp:
// Adding stuff to test smtp
// $config['smtp_port'] = 25;
$config['smtp_host'] = '%h';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';


The mail serve is postfix, and I can send mail from my home laptop through port 587 without problems.

If I change
$config['smtp_host'] = '%h';
to
$config['smtp_host'] = 'tls://%h';
I get this error: SMTP Error(): Connection to server failed.
If I change it to
$config['smtp_host'] = 'ssl://%h';
I get the same thing.

Here's some log entries:
[15-Jun-2024 14:26:54 -0500]: <d82jvoab> PHP Error: Failed to connect socket: fsockopen(): unable to connect to ssl://localhost:465 (Unknown error) (POST /webmail/?_task=mail&_unlock=loading1718479614119&_framed=1&_action=send)
[15-Jun-2024 14:26:54 -0500]: <d82jvoab> SMTP Error: Connection failed:  (Code: -1) in /var/www/html/webmail/program/lib/Roundcube/rcube.php on line 1794 (POST /webmail/?_task=mail&_unlock=loading1718479614119&_framed=1&_action=send)
[15-Jun-2024 14:27:27 -0500]: <d82jvoab> PHP Error: SMTP server does not support authentication (POST /webmail/?_task=mail&_unlock=loading1718479647193&_framed=1&_action=send)
[15-Jun-2024 14:27:27 -0500]: <d82jvoab> SMTP Error: Authentication failure: mail.stovebolt.com
PIPELINING
SIZE 900000000
VRFY
ETRN
STARTTLS
ENHANCEDSTATUSCODES
8BITMIME
DSN
SMTPUTF8
CHUNKING (Code: 250) in /var/www/html/webmail/program/lib/Roundcube/rcube.php on line 1794 (POST /webmail/?_task=mail&_unlock=loading1718479647193&_framed=1&_action=send)

In the maillogs I see this, which is clearly wrong:
Jun 14 16:47:48 ded602 postfix/smtpd[28744]: warning: unknown[80.244.11.117]: SASL LOGIN authentication failed: authentication failure, sasl_username=roundcube@mail.stovebolt.com
Jun 14 16:47:55 ded602 postfix/smtpd[27429]: warning: unknown[80.244.11.117]: SASL LOGIN authentication failed: authentication failure, sasl_username=roundcube@mail.stovebolt.com

Why is roundcube trying to login using its name instead of my username? And how do I fix that? I thought that seting smtp_user to %u meant that it would use my username. UPDATE: I should have looked at this more carefully. This is some bozo running scripts trying to login using the roundcube username.

Also, I have verified, using openssl -connect, that the mail server expects (and accepts) the username or the username@domain.tld or the username@mail.domain.tld. So, I need to configure roundcube to use the username of the logged in user. Apparently, postfix strips everything after the @ sign and just uses the name for logins.

I thought that was what smtp_user = '%u'; did, but it doesn't seem to be working.

JohnDoh

the config option `smtp_port` was removed in 1.6.0. the port is now defined as part of `smtp_host`. the default is:
`$config['smtp_host'] = 'localhost:587';`
from the logs you posted its hard to say much because you have been trying different settings and the logs are from different times.

if the host you are using is `localhost` and you are trying to connect using ssl://or tls:// then you will also need to set up `smtp_conn_options` to disable cert verification.

what smtp settings do you use from your laptop? and what is the value of %h? with that info we can probably tell you how to put the matching settings in your Roundcube config.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

pschmehl

#2
$h would be mail.stovebolt.com. Roundcube is installed on the same server as dovecot and postfix.
This is a log entry from today. This was after I added the smtp_conn_options that you mentioned.
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Connecting to stovebolt.com:25...
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 220 mail.stovebolt.com ESMTP Postfix
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Send: EHLO www.stovebolt.com
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-mail.stovebolt.com
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-PIPELINING
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-SIZE 900000000
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-VRFY
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-ETRN
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-STARTTLS
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-ENHANCEDSTATUSCODES
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-8BITMIME
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-DSN
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250-SMTPUTF8
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 250 CHUNKING
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Send: QUIT
[16-Jun-2024 12:16:33 -0500]: <eat4r6h5> Recv: 221 2.0.0 Bye
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Connecting to localhost:587...
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 220 mail.stovebolt.com ESMTP Postfix
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Send: EHLO www.stovebolt.com
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-mail.stovebolt.com
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-PIPELINING
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-SIZE 900000000
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-VRFY
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-ETRN
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-STARTTLS
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-ENHANCEDSTATUSCODES
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-8BITMIME
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-DSN
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250-SMTPUTF8
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 250 CHUNKING
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Send: QUIT
[16-Jun-2024 13:26:41 -0500]: <5s9tomcd> Recv: 221 2.0.0 Bye

This all looks perfectly normal to me

The odd thing is, I'm not seeing anything about this connection attempt in the mail logs from the same date/timestamp.
Jun 16 12:12:15 ded602 postfix/smtpd[22445]: disconnect from unknown[80.244.11.68] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
Jun 16 12:12:16 ded602 postfix/smtpd[23531]: disconnect from unknown[80.244.11.65] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
Jun 16 12:12:17 ded602 postfix/smtpd[23533]: connect from unknown[80.244.11.119]
Jun 16 12:12:17 ded602 postfix/smtpd[22551]: connect from unknown[80.94.95.242]
Jun 16 12:12:17 ded602 postfix/smtpd[22837]: connect from unknown[80.244.11.148]


Apple Mail is not exactly an informative mail client. The settings that I have are: Account: geek@stovebolt.com, Username: geek@stovebolt.com, Hostname: mail.stovebolt.com, Port: 587, Use: TLS/SSL

This is the last entry in the error log.
[16-Jun-2024 13:51:04 -0500]: <5s9tomcd> PHP Error: SMTP server does not support authentication (POST /webmail/?_task=mail&_unlock=loading1718563863923&_framed=1&_action=send)
[16-Jun-2024 13:51:04 -0500]: <5s9tomcd> SMTP Error: Authentication failure: mail.stovebolt.com
PIPELINING
SIZE 900000000
VRFY
ETRN
STARTTLS
ENHANCEDSTATUSCODES
8BITMIME
DSN
SMTPUTF8
CHUNKING (Code: 250) in /var/www/html/webmail/program/lib/Roundcube/rcube.php on line 1794 (POST /webmail/?_task=mail&_unlock=loading1718563863923&_framed=1&_action=send)
[16-Jun-2024 13:51:26 -0500]: <5s9tomcd> PHP Error: SMTP server does not support authentication (POST /webmail/?_task=mail&_unlock=loading1718563886735&_framed=1&_action=send)
[16-Jun-2024 13:51:26 -0500]: <5s9tomcd> SMTP Error: Authentication failure: mail.stovebolt.com
PIPELINING
SIZE 900000000
VRFY
ETRN
STARTTLS
ENHANCEDSTATUSCODES
8BITMIME
DSN
SMTPUTF8
CHUNKING (Code: 250) in /var/www/html/webmail/program/lib/Roundcube/rcube.php on line 1794 (POST /webmail/?_task=mail&_unlock=loading1718563886735&_framed=1&_action=send)

It's strange that it says the mail server doesn't support authentication, since I am authenticating to it from my laptop and have confirmed that I can authenitcate from the commandline using openssl connect. I'm not sure why it would say that.

Note: I have connected from the commanline to the server using the following command.
# openssl s_client -starttls smtp -connect  mail.stovebolt.com:587
Once I'm connected, I type EHLO localhost. After the response I type AUTH LOGIN. I am then prompted for a username and then a password. If I use the correct password, I'm logged in successfully. If I use an incorrect password, I get this error message.
535 5.7.8 Error: authentication failed: another step is needed in authentication
So, I can affirmatively say that postfix is enabled for authentication and is behaving as expected.

Why Roundcube thinks that the smtp server does not support authentication is a mystery to me. I have set verify_peer to false to obviate any issues with the self-signed cert.

pschmehl

This has me wondering what's going on.

This is from an openssl session to the smtp server (Postfix)
openssl s_client -starttls smtp -connect mail.stovebolt.com:587

250 CHUNKING
EHLO www.stovebolt.com
250-mail.stovebolt.com
250-PIPELINING
250-SIZE 900000000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-SMTPUTF8
250 CHUNKING


his is from the roundcube error log.

[16-Jun-2024 22:33:21 -0500]: <d0occ664> PHP Error: SMTP server does not support authentication (POST /webmail/?_task=mail&_unlock=loading1718595201337&_framed=1&_action=send)
[16-Jun-2024 22:33:21 -0500]: <d0occ664> SMTP Error: Authentication failure: mail.stovebolt.com
PIPELINING
SIZE 900000000
VRFY
ETRN
STARTTLS
ENHANCEDSTATUSCODES
8BITMIME
DSN
SMTPUTF8
CHUNKING (Code: 250) in /var/www/html/webmail/program/lib/Roundcube/rcube.php on line 1794 (POST /webmail/?_task=mail&_unlock=loading1718595201337&_framed=1&_action=send)


Notice that AUTH PLAIN LOGIN is offered in the openssl session but does not seem to be offered in the roundcube session. And STARTTLS is offered in the roundcube session but not in the openssl session.

I suspect that roundcube is reporting the PHP error:  PHP Error: SMTP server does not support authentication because it's not seeing the AUTH PLAIN LOGIN capability being offered to it.

Currently, I have this config:
$config['smtp_host'] = 'localhost:587';
$config['smtp_auth_type'] = 'PLAIN';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['smtp_conn_options'] = array(
  'ssl' => array(
    'verify_peer'  => false,
    'verify_depth' => 3,
    'cafile'       => '/etc/letsencrypt/live/mail.stovebolt.com/fullchain.pem',
  ),
);

But, if i add tls:// to the host, I get a different error message. In the client, I see SMTP ERROR(): Connection to server failed.

In the error log I see.
[16-Jun-2024 22:48:03 -0500]: <be987vif> PHP Error: STARTTLS failed (POST /webmail/?_task=mail&_unlock=loading1718596083446&_framed=1&_action=send)
[16-Jun-2024 22:48:03 -0500]: <be987vif> PHP Error: Invalid response code received from server (POST /webmail/?_task=mail&_unlock=loading1718596083446&_framed=1&_action=send)
[16-Jun-2024 22:48:03 -0500]: <be987vif> SMTP Error: STARTTLS failed: 2.0.0 Ready to start TLS (Code: 220) in /var/www/html/webmail/program/lib/Roundcube/rcube.php on line 1794 (POST /webmail/?_task=mail&_unlock=loading1718596083446&_framed=1&_action=send)


Is I change the host to ssl://localhost:587, I get the same error in the client, but the error log entry is different.
[16-Jun-2024 22:55:06 -0500]: <be987vif> PHP Error: Failed to connect socket: stream_socket_client(): unable to connect to ssl://localhost:587 (Unknown error) (POST /webmail/?_task=mail&_unlock=loading1718596505795&_framed=1&_action=send)
[16-Jun-2024 22:55:06 -0500]: <be987vif> SMTP Error: Connection failed:  (Code: -1) in /var/www/html/webmail/program/lib/Roundcube/rcube.php on line 1794 (POST /webmail/?_task=mail&_unlock=loading1718596505795&_framed=1&_action=send)


Maybe some of this will help trigger some thoughts?

JohnDoh

could it be smtp authentication is not enabled for connections to localhost in postfix?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

pschmehl

Since I can connect and auth using openssl from the cli, I don't think it's a problem. I did find a problem with my postfix setup, and I'm now getting a different error message. It looks like I may have more problems with my postfix setup.

Here's my config:
$config['smtp_host'] = 'tls://mail.stovebolt.com:465';
$config['smtp_auth_type'] = 'PLAIN';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';


And here's what I now see in the mail logs:
Jun 18 03:48:37 ded602 postfix/smtpd[25832]: connect from stovebolt.com[108.174.193.28]
Jun 18 03:48:37 ded602 postfix/smtpd[25832]: setting up TLS connection from stovebolt.com[108.174.193.28]
Jun 18 03:48:37 ded602 postfix/smtpd[25832]: stovebolt.com[108.174.193.28]: TLS cipher list "aNULL:-aNULL:HIGH:MEDIUM:!SEED:!IDEA:!3DES:!RC2:!RC4:!RC5:!kDH:!kECDH:!aDSS:!MD5:+RC4:@STRENGTH"


And this is what I see in the roundcube smtp log:
[18-Jun-2024 02:48:37 -0500]: <kudbhq2l> Connecting to tls://mail.stovebolt.com:465...

And this is what I see in the roundcube error log:
[18-Jun-2024 02:53:37 -0500]: <kudbhq2l> PHP Error: Invalid response code received from server (POST /webmail/?_task=mail&_unlock=loading1718696917442&_framed=1&_action=send)
[18-Jun-2024 02:53:37 -0500]: <kudbhq2l> SMTP Error: Connection failed:  (Code: -1) in /var/www/html/webmail/program/lib/Roundcube/rcube.php on line 1794 (POST /webmail/?_task=mail&_unlock=loading1718696917442&_framed=1&_action=send)


alec

Typically you use ssl:// prefix on port 465 and tls:// on port 587.