Roundcube Community Forum

 

Multi-domain

Started by alain25, April 26, 2024, 01:09:18 PM

Previous topic - Next topic

alain25

Hello everyone,

Server: unbuntu 20.04
Mail server: postfix

I am on ubuntu 20.04 with a postfix and postfixadmin for the mutidomain with a database.
Also, I installed Roundcube 1.6.5 with a database.
It works very well for a single domain.

I tried to put Roundcube in multi-domain.
I followed the following tutorial: https://github.com/roundcube/roundcubemail/wiki/Configuration%3A-Multi-Domain-Setup

First, I added the variable $config['include_host_config to the config.inc.php file.
Then I added the lines below:

$config['include_host_config'] = array(
    mail.rdomain1.tld' => 'domain1_config.inc.php',
    mail.domain2.tld' => 'domain2_config.inc.php',
    mail.domain3.tld' => 'domain3_config.inc.php',
);


Then I created one file per domain. But it doesn't work.

Do you have a solution?

Thanks

Alain

JohnDoh

#1
You have not given us a lot to go on. Your host config files are in the same location as the main config file correct? And have the same owner and permissions? If there is nothing in the Rounscube error log you may need to do a bit of code diving to find the answer. This is the code that does the work https://github.com/roundcube/roundcubemail/blob/master/program/lib/Roundcube/rcube_config.php#L261
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

alain25

Hello,

Sorry for my very late reply, I've redone the whole server.

I'm just missing roundcube.

What information do you need?

I followed the Linux Babe documentation https://www.linuxbabe.com/ubuntu/install-roundcube-webmail-ubuntu-20-04-apache-nginx under apache2

Thanks

Merci

JohnDoh

Please describe the issue you are facing in as much detail as possible, "it doesn't work" could be anything. What error message do you receive on the screen, is there anything in the Roundcube or your IMAP server error logs?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

alain25

Bonjour,

To better explain, I've replaced

$config['imap_host'] = 'ssl://mail.domain1.tld:993';
$config['smtp_host'] = 'ssl://mail.domain1.tld:465';

by

$config['include_host_config'] = array(
    mail.domain1.tld' => 'domain1_config.inc.php',
    mail.domain2.tld' => 'domain2_config.inc.php',
);

Here's the error message in my logs !

syntax error, unexpected single-quoted string " => ", expecting ")" in /var/www/roundcube/config/config.inc.php on line 279

I followed the documentation of Configuration: Multi Domain Setup https://github.com/roundcube/roundcubemail/wiki/Configuration:-Multi-Domain-Setup

In the domain1_config.inc.php file I've put

<?php

// ---------------------------------------------------------------------
// configuration to config.inc.php.
// ---------------------------------------------------------------------


// ----------------------------------
// IMAP
// ----------------------------------

// The IMAP host (and optionally port number) chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// Enter hostname with prefix ssl:// to use Implicit TLS, or use
// prefix tls:// to use STARTTLS.
// If port number is omitted it will be set to 993 (for ssl://) or 143 otherwise.
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
//          required to match old user data records with the new host.
//$config['imap_host'] = 'localhost:143';

$config['imap_host'] = 'ssl://mail.domain1.com:993';

// ----------------------------------
// SMTP
// ----------------------------------

// SMTP server host (and optional port number) for sending mails.
// Enter hostname with prefix ssl:// to use Implicit TLS, or use
// prefix tls:// to use STARTTLS.
// If port number is omitted it will be set to 465 (for ssl://) or 587 otherwise.
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
// To specify different SMTP servers for different IMAP hosts provide an array
// of IMAP host (no prefix or port) and SMTP server e.g. ['imap.example.com' => 'smtp.example.net']
//$config['smtp_host'] = 'localhost:587';
[img]https://vaultwarden.osnetworking.com:5001/#/send/evOcjr5WR_6ld8Fe1ME9kA/mnaFvJJTcEgdkXqXB3VzEQ[/img]
$config['smtp_host'] = 'ssl://mail.domain1.com:465';

Is it necessary to create a database for each domain?nana

When I try to send a message, I get an error:

https://vaultwarden.osnetworking.com:5001/#/send/evOcjr5WR_6ld8Fe1ME9kA/mnaFvJJTcEgdkXqXB3VzEQ






JohnDoh

First, fix your syntax error. I'm guessing line 279 in your config file is the first entry in your `include_host_config` array. If so, add the missing ' before the start of the key name, same thing for the second one. (assuming thats not just some copy/paste or forum message display thing that they are missing in the snippet you posted).
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

alain25

I've corrected the syntax error

$config['include_host_config'] = array(
    [b]'[/b]mail.roundcube.net' => 'net_config.inc.php',
    [b]'[/b]mail.roundcube.com' => 'com_config.inc.php',
);
As the example : https://github.com/roundcube/roundcubemail/wiki/Configuration:-Multi-Domain-Setup

Now, i got an error to send the messages:

ERROR SMTP (): Authentication failed

unable to send message.

On the other hand I receive the message but I can't open it, I get an error message too:


QuoteOops .. Something went wrong!

An internal erreor has occurred. You request canont be pressed at this time.

For administrator : Please check the application and/or server logs for more information.

In the logs /var/log/apache2/roundcube_mondomain1.tld_error.log, I have no further information.

in the file inc.config.php
I've activated some functions to get the logs.

// ----------------------------------
// LOGGING/DEBUGGING
// ----------------------------------

// log driver:  'syslog', 'stdout' or 'file'.
$config['log_driver'] = 'file';

// date format for log entries
// (read http://php.net/manual/en/function.date.php for all format characters)
$config['log_date_format'] = 'd-M-Y H:i:s O';

// length of the session ID to prepend each log line with
// set to 0 to avoid session IDs being logged.
$config['log_session_id'] = 8;

// Default extension used for log file name
$config['log_file_ext'] = '.log';

// Syslog ident string to use, if using the 'syslog' log driver.
$config['syslog_id'] = 'roundcube';

// Syslog facility to use, if using the 'syslog' log driver.
// For possible values see installer or http://php.net/manual/en/function.openlog.php
$config['syslog_facility'] = LOG_USER;

// Activate this option if logs should be written to per-user directories.
// Data will only be logged if a directory <log_dir>/<username>/ exists and is writable.
$config['per_user_logging'] = false;

// Log sent messages to <log_dir>/sendmail.log or to syslog
$config['smtp_log'] = true;

// Log successful/failed logins to <log_dir>/userlogins.log or to syslog
$config['log_logins'] = true;

// Log session debug information/authentication errors to <log_dir>/session.log or to syslog
$config['session_debug'] = true;

// Log SQL queries to <log_dir>/sql.log or to syslog
$config['sql_debug'] = false;

// Log IMAP conversation to <log_dir>/imap.log or to syslog
$config['imap_debug'] = true;

// Log LDAP conversation to <log_dir>/ldap.log or to syslog
$config['ldap_debug'] = false;

// Log SMTP conversation to <log_dir>/smtp.log or to syslog
$config['smtp_debug'] = true;

// Log Memcache conversation to <log_dir>/memcache.log or to syslog
$config['memcache_debug'] = false;

// Log APC conversation to <log_dir>/apc.log or to syslog
$config['apc_debug'] = false;

// Log Redis conversation to <log_dir>/redis.log or to syslog
$config['redis_debug'] = false;

How to get more information from roundcube logs?
How to solve problems?

Thanks


JohnDoh

Look in [rc root]/logs/ for the error log file, make sure permissions are set correctly so the php user can write to that folder.

BTW did you use the installer to do your Roundcube installation? I ask because an internal error like that when viewing a message often means you are missing the PHP DOM extension and the installer would have picked that up.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

alain25

#8
Hello,

I've just checked for the PHP DOM :

root@mail:/var/www/roundcube/config# php -v

PHP 8.1.2-1ubuntu2.20 (cli) (built: Dec  3 2024 20:14:35) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.20, Copyright (c), by Zend Technologies


root@mail:/var/www/roundcube/config# apt install php8.1-xml
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances... Fait
Lecture des informations d'état... Fait

php8.1-xml est déjà la version la plus récente (8.1.2-1ubuntu2.20).
0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour.


The permissions in this folder /var/www/roundcube/ are :

root@mail:/var/www/roundcube# ll
total 408
drwxrwxr-x 12 www-data www-data   4096 juin  15  2024 ./
drwxr-xr-x  8 root     root       4096 juin  24  2024 ../
drwxrwxr-x  2 www-data www-data   4096 mai   19  2024 bin/
-rw-rw-r--  1 www-data www-data 213794 mai   19  2024 CHANGELOG.md
-rw-rw-r--  1 www-data www-data    994 mai   19  2024 composer.json
-rw-rw-r--  1 www-data www-data   1086 mai   19  2024 composer.json-dist
-rw-rw-r--  1 www-data www-data  56852 mai   19  2024 composer.lock
drwxrwxr-x  2 www-data www-data   4096 déc.  30 18:02 config/
-rw-rw-r--  1 www-data www-data   2553 mai   19  2024 .htaccess
-rw-rw-r--  1 www-data www-data  11199 mai   19  2024 index.php
-rw-rw-r--  1 www-data www-data  12661 mai   19  2024 INSTALL
-rw-rw-r--  1 www-data www-data  35147 mai   19  2024 LICENSE
drwxrwxr-x  2 www-data www-data   4096 déc.  30 17:36 logs/
drwxrwxr-x 40 www-data www-data   4096 juin  22  2024 plugins/
drwxrwxr-x  8 www-data www-data   4096 mai   19  2024 program/
drwxrwxr-x  3 www-data www-data   4096 mai   19  2024 public_html/
-rw-rw-r--  1 www-data www-data   3853 mai   19  2024 README.md
-rw-rw-r--  1 www-data www-data    967 mai   19  2024 SECURITY.md
drwxrwxr-x  3 www-data www-data   4096 mai   19  2024 skins/
drwxrwxr-x  7 www-data www-data   4096 mai   19  2024 SQL/
drwxrwxr-x  2 www-data www-data   4096 juil.  6 21:36 temp/
-rw-rw-r--  1 www-data www-data   4657 mai   19  2024 UPGRADING
drwxrwxr-x 14 www-data www-data   4096 mai   19  2024 vendor/

For Roundcube logs, I put them in /var/logs/apache2/roundcube-domain1-error.log and /var/logs/apache2/roundcube-domain1-access.log


In my log file /var/logs/apache2/roundcube-domain1-error.log, I have no error.

Here are the permissions of my log files:

-rw-r--r--  1 root root    62422 déc.  31 11:14 roundcube_domaine1_access.log
-rw-r--r--  1 root root        0 déc.  30 12:52 roundcube_domaine1_error.log
-rw-r--r--  1 root root   132314 déc.  31 02:28 roundcube_domaine2_access.log
-rw-r--r--  1 root root       10 déc.  31 11:11 roundcube_domaine2_error.log

On mail clients it works fine.




JohnDoh

Typically cli PHP and PHP used by Apache use different configs. They could be very similar but doing checks against cli PHP like that can be misleading if you are trying to debug an Apache application. Similarly having the php-xml package installed does not mean it is enabled in your PHP config.

I'm not saying thats the issue, only a possible cause. To get the answer you need to look at the Roundcube error log. That is different to the Apache error log.
QuoteFor Roundcube logs, I put them in /var/logs/apache2/roundcube-domain1-error.log and /var/logs/apache2/roundcube-domain1-access.log
Those look like are your Apache server logs, Roundcube does not write access logs or log files with those names. Because you are using the "file" driver for your Roundcube application logging the location is defined in the `log_dir` Roundcube config option. The default is <rc root>/logs. The permssions you posted look ok so if you look in that folder hopefully you will see an errors.log file.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

alain25

Hello,

Happy New Year!

I can't find in the root Logs folder but maybe, I'm in the wrong folder.

root@mail:~# ll
total 156
drwx------  8 root root  4096 déc.  27 18:55 ./
drwxr-xr-x 20 root root  4096 nov.  26 21:19 ../
-rw-------  1 root root 75215 déc.  31 13:42 .bash_history
-rw-r--r--  1 root root  3106 oct.  15  2021 .bashrc
drwxr-xr-x  3 root root  4096 juin  24  2024 .cpanm/
-rw-------  1 root root    20 déc.  27 18:55 .lesshst
drwxr-xr-x  3 root root  4096 mai   20  2024 .local/
-rw-------  1 root root  6038 mai   31  2024 .mysql_history
-rw-r--r--  1 root root   161 juil.  9  2019 .profile
-rw-r--r--  1 root root    66 mai   25  2024 .selected_editor
drwx------  3 root root  4096 mai   19  2024 snap/
drwx------  2 root root  4096 mai   19  2024 .ssh/
-rw-r--r--  1 root root     0 mai   19  2024 .sudo_as_admin_successful
drwxr-xr-x  2 root root  4096 juin  24  2024 tmp/
drwxr-xr-x  2 root root  4096 juin   8  2024 .vim/
-rw-------  1 root root 13520 juil.  5 20:55 .viminfo
-rw-r--r--  1 root root   255 juin  24  2024 .wget-hsts

I do cd /root and even in root I don't have a folder

root@mail:/# ll
total 4019288
drwxr-xr-x  20 root root       4096 janv.  1 13:06 ./
drwxr-xr-x  20 root root       4096 janv.  1 13:06 ../
lrwxrwxrwx   1 root root          7 avril 21  2022 bin -> usr/bin/
drwxr-xr-x   5 root root       4096 janv.  1 06:28 boot/
drwxr-xr-x  20 root root       4140 déc.  31 18:24 dev/
drwxr-xr-x 120 root root      12288 déc.  31 10:51 etc/
drwxr-xr-x   7 root root       4096 nov.  26 21:19 home/
lrwxrwxrwx   1 root root          7 avril 21  2022 lib -> usr/lib/
lrwxrwxrwx   1 root root          9 avril 21  2022 lib32 -> usr/lib32/
lrwxrwxrwx   1 root root          9 avril 21  2022 lib64 -> usr/lib64/
lrwxrwxrwx   1 root root         10 avril 21  2022 libx32 -> usr/libx32/
drwx------   2 root root      16384 mai   19  2024 lost+found/
drwxr-xr-x   2 root root       4096 avril 21  2022 media/
drwxr-xr-x   2 root root       4096 avril 21  2022 mnt/
drwxr-xr-x   6 root root       4096 déc.  24 16:43 opt/
dr-xr-xr-x 334 root root          0 déc.  31 18:24 proc/
drwx------   8 root root       4096 déc.  27 18:55 root/
drwxr-xr-x  38 root root       1100 janv.  1 12:56 run/
lrwxrwxrwx   1 root root          8 avril 21  2022 sbin -> usr/sbin/
drwxr-xr-x   6 root root       4096 avril 21  2022 snap/
drwxr-xr-x   2 root root       4096 avril 21  2022 srv/
-rw-------   1 root root 4115660800 mai   19  2024 swap.img
drwxr-xr-x   2 root root       4096 nov.  26 21:19 .synosnap_data/
dr-xr-xr-x  13 root root          0 déc.  31 18:24 sys/
drwxrwxrwt  16 root root       4096 janv.  1 13:09 tmp/
drwxr-xr-x  14 root root       4096 avril 21  2022 usr/
drwxr-xr-x  14 root root       4096 mai   20  2024 var/
root@mail:/#

Can you help me find the folder?

Thanks

JohnDoh

<rc root> = the root directory of your Roundcube installation. Based on the dir listing you posted earlier you want to look in /var/www/roundcube/logs. That listed showed www-data already has write access and hopefully that's the right user so you will find a errors.log file in there.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

alain25

#12
Here is the logs :

:/var/www/roundcube/logs$ tail -f errors.log
#5 /var/www/roundcube/program/include/rcmail_output_html.php(1615): rcube_plugin_api->exec_hook()
#6 [internal function]: rcmail_output_html->xml_command()
#7 /var/www/roundcube/program/include/rcmail_output_html.php(1322): preg_replace_callback()
#8 /var/www/roundcube/program/include/rcmail_output_html.php(825): rcmail_output_html->parse_xml()
#9 /var/www/roundcube/program/include/rcmail_output_html.php(654): rcmail_output_html->parse()
#10 /var/www/roundcube/program/actions/mail/show.php(164): rcmail_output_html->send()
#11 /var/www/roundcube/program/include/rcmail.php(282): rcmail_action_mail_show->run()
#12 /var/www/roundcube/index.php(278): rcmail->action_handler()
#13

 {mai thrown in /var/www/roundcube/plugins/libcalendaring/lib/libcalendaring_vcalendar.php on line 1576
[01-Jan-2025 17:21:40 Europe/Berlin] PHP Warning:  Undefined array key "Y-m-d" in /var/www/roundcube/plugins/libcalendaring/libcalendaring.php on line 302
[01-Jan-2025 17:21:40 Europe/Berlin] PHP Warning:  Undefined array key "Y-m-d" in /var/www/roundcube/plugins/libcalendaring/libcalendaring.php on line 302
[01-Jan-2025 17:22:12 Europe/Berlin] PHP Warning:  Undefined array key "Y-m-d" in /var/www/roundcube/plugins/libcalendaring/libcalendaring.php on line 302
[01-Jan-2025 17:22:12 +0100]: <c5pffs2e> PHP Error: SMTP server does not support authentication (POST /?_task=mail&_unlock=loading1735748531542&_framed=1&_lang=fr_FR&_action=send)
[01-Jan-2025 17:22:12 +0100]: <c5pffs2e> SMTP Error: Authentication failure: mail.domaine1.tld
PIPELINING
SIZE 52428800
VRFY
ETRN
STARTTLS
ENHANCEDSTATUSCODES
8BITMIME
DSN
CHUNKING (Code: 250) in /var/www/roundcube/program/lib/Roundcube/rcube.php on line 1794 (POST /?_task=mail&_unlock=loading1735748531542&_framed=1&_lang=fr_FR&_action=send)
[01-Jan-2025 17:22:37 Europe/Berlin] PHP Warning:  Undefined array key "Y-m-d" in /var/www/roundcube/plugins/libcalendaring/libcalendaring.php on line 302
[01-Jan-2025 17:22:37 +0100]: <c5pffs2e> PHP Error: SMTP server does not support authentication (POST /?_task=mail&_unlock=loading1735748556783&_framed=1&_lang=fr_FR&_action=send)
[01-Jan-2025 17:22:37 +0100]: <c5pffs2e> SMTP Error: Authentication failure: mail.domaine1.tld
PIPELINING
SIZE 52428800
VRFY
ETRN
STARTTLS
ENHANCEDSTATUSCODES
8BITMIME
DSN
CHUNKING (Code: 250) in /var/www/roundcube/program/lib/Roundcube/rcube.php on line 1794 (POST /?_task=mail&_unlock=loading1735748556783&_framed=1&_lang=fr_FR&_action=send)
n}
  thrown in /var/www/roundcube/plugins/libcalendaring/lib/libcalendaring_vcalendar.php on line 1576

I did a test send, here are the results above.

JohnDoh

Because you have only posted the second half of the stack trace I cannot see what the actual error was. I can see it comes from the third-party plugin libcalendaring. I suggest you disable all Roundcube plugins while you get your basic install working. Then start with any core plugins and then third-party ones. For third-party ones you should check if there is any documentation provided with those plugins that lists any special requirements.

I have never used the libcalendaring plugin myself but a quick search suggests may be you are missing the Sabre/VObject PHP lib?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...