Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP not working when in same Docker Stack as Mailserver #9705

Open
2 tasks done
felixlabrot opened this issue Nov 17, 2024 · 8 comments
Open
2 tasks done

SMTP not working when in same Docker Stack as Mailserver #9705

felixlabrot opened this issue Nov 17, 2024 · 8 comments

Comments

@felixlabrot
Copy link

Prerequisites

  • I have searched for duplicate or closed issues
  • I can recreate the issue with all plugins disabled

Describe the issue

This is actually two bugs which occur uppon setup.

I have a Roundcube installation via Docker which is included in the same Docker Stack as the Mailserver is. It is possible to login and read mails.

No. 1:
Attempting to delete an email results in the error message "UID MOVE: Account not found". Only after manually setting the "Deleted Items" folder in the special folder settings it works. This setting has to be done by every user manually. This is extremely problematic as explaining this to every new user is just insane and not practically doable.

No. 2:
Also SMTP is in complete denial. When attempting to send an email it shows the message that it is working forever. No mail is sent and no error shows up. It just keeps loading forever.

This is the Docker Stack:

volumes:
  stalwart-data:
  roundcube-data:
  roundcube-database:

services:
  stalwartmail:
    container_name: stalwartmail
    image: stalwartlabs/mail-server:latest
    volumes:
      - stalwart-data:/opt/stalwart-mail
    ports:
      - 443:443
      - 8080:8080
      - 25:25
      - 587:587
      - 465:465
      - 143:143
      - 993:993
      - 4190:4190
      - 110:110
      - 995:995
    restart: always

  roundcube:
    container_name: roundcube-server
    image: roundcube/roundcubemail:latest-apache
    ports:
      - 8000:80
    volumes:
      - roundcube-data:/var/www/html
    environment:
      ROUNDCUBEMAIL_DEFAULT_HOST: stalwartmail
      ROUNDCUBEMAIL_DEFAULT_PORT: 143
      ROUNDCUBEMAIL_SMTP_SERVER: tls://stalwartmail
      ROUNDCUBEMAIL_SMTP_PORT: 465
      ROUNDCUBEMAIL_REQUEST_PATH: /
      ROUNDCUBEMAIL_PLUGINS: archive,zipdownload
      ROUNDCUBEMAIL_INSTALL_PLUGINS: true
      ROUNDCUBEMAIL_SKIN: elastic
      ROUNDCUBEMAIL_UPLOAD_MAX_FILESIZE: 10M
      ROUNDCUBEMAIL_DB_TYPE: mysql
      ROUNDCUBEMAIL_DB_HOST: roundcubedatabase
      ROUNDCUBEMAIL_DB_PORT: 3306
      ROUNDCUBEMAIL_DB_USER: roundcubemail
      ROUNDCUBEMAIL_DB_PASSWORD: xxxxxx
      ROUNDCUBEMAIL_DB_NAME: roundcubemail
    restart: always
    depends_on:
      - roundcubedatabase

  roundcubedatabase:
    container_name: roundcube-database
    image: mariadb:latest
    volumes:
      - roundcube-database:/var/lib/mysql
    environment:
      MARIADB_ROOT_PASSWORD: xxxxxx
      MARIADB_USER: roundcubemail
      MARIADB_PASSWORD: xxxxxx
      MARIADB_DATABASE: roundcubemail
    restart: always

I have manually added this config:

$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['smtp_auth_type'] = 'PLAIN';
$config['smtp_conn_options'] = [
  'ssl' => [
    'verify_peer' => false,
    'peer_name' => 'mail.example.com',
  ]
];

The SMTP server expects plaintext authentication and runs in TLS mode with a valid certificate, but TLS doesn't work within Docker due to different hostnames.

What browser(s) are you seeing the problem on?

No response

What version of PHP are you using?

No response

What version of Roundcube are you using?

1.6.9

JavaScript errors

No response

PHP errors

No response

@MrSuddenJoy
Copy link

This is extremely problematic as explaining this to every new user is just insane and not practically doable.

@felixlabrot why is this? Cannot you just put global anouncement?

@felixlabrot
Copy link
Author

This is extremely problematic as explaining this to every new user is just insane and not practically doable.

@felixlabrot why is this? Cannot you just put global anouncement?

That could be done but for something that should work out of the box (and does in Thunderbird) it is generally inacceptable to tell people to manually configure something for the possibility to delete mails. That is not user friendly for internal use. When using for customers it looks highly unprofessional that something this simple is broken on first login and has to be manually configured.

@alecpl
Copy link
Member

alecpl commented Nov 18, 2024

Sounds like configuration issues. I think this may belong to https://github.com/roundcube/roundcubemail-docker/issues.

  1. Try with $config['create_default_folders'] = true;.
  2. Try with $config['smtp_host'] = 'tls://localhost:587';.

Maybe these should be defaults in the next release.

@felixlabrot
Copy link
Author

Sounds like configuration issues. I think this may belong to https://github.com/roundcube/roundcubemail-docker/issues.

1. Try with `$config['create_default_folders'] = true;`.

2. Try with `$config['smtp_host'] = 'tls://localhost:587';`.

Maybe these should be defaults in the next release.

The automatic creation of those folders is done by default anyways. I have for test purposes created a new user with a new mailbox and after creation I've logged in to Roundcube, which automatically created all folders and filled them out correctly. So apparently it is a bug that for some accounts this has to be manually configured. On the affected accounts this also has to be reconfigured in random intervals, as the settings just get lost. Yesterday I've set all special folders on my personal mailbox and today 2 of 4 settings have vanished.

Below I've documented what all the possible combinations of ports and protocols do - for those who may look at this issue in the future.

Those options work:

  • $config['smtp_host'] = 'ssl://stalwartmail:465';
  • $config['smtp_host'] = 'tls://stalwartmail:587';

Those config options lead to a forever loading screen when sending:

  • $config['smtp_host'] = 'tls://stalwartmail:465';
  • $config['smtp_host'] = 'stalwartmail:465';

Those options lead to a connection error with empty error message:

  • $config['smtp_host'] = 'ssl://stalwartmail:587';
  • $config['smtp_host'] = 'ssl://stalwartmail:25';

Those options lead to a authentication error with empty error message:

  • $config['smtp_host'] = 'tls://stalwartmail:25';
  • $config['smtp_host'] = 'stalwartmail:25';

Those options lead to a authentication error with 554 error message:

  • $config['smtp_host'] = 'stalwartmail:587';

This concludes that $config['smtp_host'] = 'ssl://stalwartmail:465'; and $config['smtp_host'] = 'tls://stalwartmail:587'; are the only valid options.

This leaves the only issue that some special folder configurations vanish overnight.

@MrSuddenJoy
Copy link

Maybe these should be defaults in the next release.

@alecpl would be great 👍🏻

@pabzm
Copy link
Member

pabzm commented Nov 20, 2024

To me this sounds like buggy error messaging when failing to verify TLS/SSL-connections.

So apparently it is a bug that for some accounts this has to be manually configured

Can you reproduce the bug?

@felixlabrot
Copy link
Author

The messages could be better, but if you can access the mailserver logs, this isn't too much of an issue.

It would be very helpful if IMAP/SMTP errors would show up in the Docker logs of the Roundcube container.

In the cases where it shows the sending in progress forever, this needs a timeout and an error message to be shown.

@pabzm I can reproduce the bug but this is unreliable and sometimes occurs and sometimes doesn't. I wasn't able to find a way to reliably reproduce the bug so far. I'll follow up with more useful insights then.

@felixlabrot
Copy link
Author

The issue was caused by a bug in Stalwart, the external mailserver.
Roundcube needs a proper error message when having TLS issues and have the forever sending thing given a timeout and a proper error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants