Author Topic: Subdomain with custom softacolous roundcube installation with 2 servers  (Read 1999 times)

Offline georgi

  • Newbie
  • *
  • Posts: 5
Hi,

I recently set up RoundCube on a subdomain and was able to successfully log in using email accounts from different servers. The IMAP settings in the RoundCube configuration file are as follows:

$config['imap_host'] = array(
'ssl://hostname1.com:993',
'ssl://hostname2.com:993'
);

I am able to log in to the different email accounts on the different servers without any issue. However, I am encountering an SMTP error 500 when trying to send an email. I have tried both port 465 and 587 with SSL, and also tried using different authentication credentials for the SMTP server, but the issue persists.

I have set up the SMTP settings in the RoundCube configuration file as follows:

$config['smtp_host'] = array(
'ssl://hostname1.com:465' => array(
'smtp_user' => 'account1',
'smtp_pass' => 'password1',
'smtp_server' => 'hostname1.com'
),
'ssl://hostname2.com:465' => array(
'smtp_user' => 'account2',
'smtp_pass' => 'password2',
'smtp_server' => 'hostname2.com'
)
);

I would appreciate any help or suggestions on how to resolve this issue. Let me know if there is any additional information I can provide to help diagnose the problem.

Thank you.

Offline Dmitry42

  • Full Member
  • ***
  • Posts: 232
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #1 on: February 12, 2023, 08:40:57 PM »
In defaults you can see:
// 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']

so one way i think you must use config like this:
$config['smtp_host'] = array(
   ['hostname1.com'=>'hostname1.com'],
    ['hostname2.com'=>'hostname2.com']
);


Second way if your IMAP and SMTP servers on one host for ever domain - like imap and smtp on mail.domain1.com (not on imap.domain1.com and smtp.domain1.com) and you can try this:

// 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.
$config['imap_host'] = array(
'ssl://hostname1.com',
'ssl://hostname2.com'
);

// 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
$config['smtp_host'] = '%h';



and don't forget about smtp auth:

// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login
// $config['smtp_user'] = '%u';
$config['smtp_user'] = '%u';

// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login
//$config['smtp_pass'] = '%p';
$config['smtp_pass'] = '%p';

And you check yous SMTP with another client (outlook and etc) - it work, sure ?
And what you see in smtp logs ?
« Last Edit: February 12, 2023, 09:09:27 PM by Dmitry42 »

Offline georgi

  • Newbie
  • *
  • Posts: 5
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #2 on: February 13, 2023, 01:27:59 AM »
In defaults you can see:
// 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']

so one way i think you must use config like this:
$config['smtp_host'] = array(
   ['hostname1.com'=>'hostname1.com'],
    ['hostname2.com'=>'hostname2.com']
);


Second way if your IMAP and SMTP servers on one host for ever domain - like imap and smtp on mail.domain1.com (not on imap.domain1.com and smtp.domain1.com) and you can try this:

// 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.
$config['imap_host'] = array(
'ssl://hostname1.com',
'ssl://hostname2.com'
);

// 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
$config['smtp_host'] = '%h';



and don't forget about smtp auth:

// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login
// $config['smtp_user'] = '%u';
$config['smtp_user'] = '%u';

// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login
//$config['smtp_pass'] = '%p';
$config['smtp_pass'] = '%p';

And you check yous SMTP with another client (outlook and etc) - it work, sure ?
And what you see in smtp logs ?

Hi,

I have tried the different configurations that you have suggested, however, I am still facing the issue with the SMTP server not being able to take the credentials for the second and third servers. I am currently in a shared hosting environment and my rights are limited in viewing the logs. However, I have tested the credentials for the second and third servers in Thunderbird and they are working without any issues.

Based on my current configuration:

php

$config['imap_host'] = array(
'ssl://hostname1.com:993',
'ssl://hostname2.com:993',
'ssl://hostname3.com:993'
);

$config['smtp_host'] = '%h';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';

I am still not able to send emails from the second and third servers, however, now I am able to completely send from the first one that is provided in the IMAP settings. I would greatly appreciate your further assistance in resolving this issue.

Thanks,

Offline Dmitry42

  • Full Member
  • ***
  • Posts: 232
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #3 on: February 13, 2023, 02:50:20 AM »
Your current config look good, you use RC 1.6.x ?
Are you use login,for example, like: username@hostname2.com ? In RC interface you see your login for hostname2 ?
Imap login work for all hostnames? not work only smtp ?


I think I make mistake in last example, try like this (without additional [] ):
$config['smtp_host'] =[
   'hostname1.com'=>'hostname1.com',
   'hostname2.com'=>'hostname2.com'
];

it will be the same as:

$config['smtp_host'] = array(
   'hostname1.com'=>'hostname1.com',
   'hostname2.com'=>'hostname2.com'
);


Offline georgi

  • Newbie
  • *
  • Posts: 5
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #4 on: February 13, 2023, 03:31:05 AM »
Your current config look good, you use RC 1.6.x ?
Are you use login,for example, like: username@hostname2.com ? In RC interface you see your login for hostname2 ?
Imap login work for all hostnames? not work only smtp ?


I think I make mistake in last example, try like this (without additional [] ):
$config['smtp_host'] =[
   'hostname1.com'=>'hostname1.com',
   'hostname2.com'=>'hostname2.com'
];

it will be the same as:

$config['smtp_host'] = array(
   'hostname1.com'=>'hostname1.com',
   'hostname2.com'=>'hostname2.com'
);

To not make this more difficult than it already is, I am going to answer your questions in the order that you have asked them.

1. Yes the version of the RoundCube that I am using is 1.6.1
2. The login that I am using is not email@hostname.com yet rather a email@domain.com where the domain is in that server and the MX record is pointed to it.
3. Yes I am seeing the account in the RC, e.g the account that I am login in utilizing IMAP settings from the server.
4. Yes IMAP login is working perfectly fine for all three servers in that regard the IMAP config is alright furthermore I am completely able now to send emails from the server that is listed as server number 1 in the IMAP hostnames configuration. Furthermore, I am able to send emails from multiple email accounts on that server, however, when I try to send emails from email accounts that are hosted on different servers, I am receiving the error SMTP Error Authentication Failed (). And I do not understand why this is happening because I am completely able to log in without any issues at all and the hostname is the same.

 

Offline Dmitry42

  • Full Member
  • ***
  • Posts: 232
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #5 on: February 13, 2023, 05:03:14 AM »
Your RC installed standalone or on one of hostname (may be on hostname1) ?

Now I think its work like this:
0. Your RC installed on hostname1 with mail.domain1.com
1. For example you have domain2.com with server mail.domain2.com
2. When you try send mail from user@domain2.com - RC take your hostname ('%h') from users IMAP hostname (ssl://mail.domain2.com:993), but it's only clear hostname without SSL prefix and PORT = mail.domain2.com
3. RC try connect to mail.domain2.com without SSL and PORTs (465 or 587)  - so it connect by standart 25 port = SMTP connect to mail.domain2.com:25 and here it can be rejected by SMTP rules like
Quote
smtpd_helo_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        reject_invalid_helo_hostname,
        reject_unknown_helo_hostname,
        reject_non_fqdn_helo_hostname
because
Quote
// SMTP HELO host
// Hostname to give to the remote server for SMTP 'HELO' or 'EHLO' messages
// Leave this blank and you will get the server variable 'server_name' or
// localhost if that isn't defined.
$config['smtp_helo_host'] = '';

So here you have 3 way:
a)need use additional string $config['smtp_helo_host'] = 'yourRChostname.com'; - its additional params for SMTP auth session

b)may be (im not sure, but why not test it  ;) ) possible write config like this: $config['smtp_host'] = 'ssl://' + '%h' + '465';

c) try here (according to alecpl comment https://coder.social/roundcube/roundcubemail/issues/8364 ):
Quote
$config['smtp_host'] =[
   'mail.domain1.com'=>'ssl://mail.domain1.com:465',
   'mail.domain2.com'=>'ssl://mail.domain2.com:465'
];

it will be the same as:

$config['smtp_host'] = array(
   'mail.domain1.com'=>'ssl://mail.domain1.com:465',
   'mail.domain2.com'=>'ssl://mail.domain2.com:465'
);
« Last Edit: February 13, 2023, 05:10:50 AM by Dmitry42 »

Offline georgi

  • Newbie
  • *
  • Posts: 5
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #6 on: February 13, 2023, 05:39:43 AM »
Hi, this is my current config and I have tried everything that you have offered, however to no avail:
Code: [Select]
$config['smtp_helo_host'] = array(
'hostname1.com'=>'hostname1.com:465',
'hostname2.com'=>'hostname2.com:465',
'hostname3.com'=>'hostname3.com:465'
);

$config['smtp_host'] = array(
'hostname1.com'=>'ssl://hostname1.com:465',
'hostname2.com'=>'ssl://hostname2.com:465',
'hostname3.com'=>'ssl://hostname3.com:465'
);

$config['smtp_host'] = '%h';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';

Offline Dmitry42

  • Full Member
  • ***
  • Posts: 232
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #7 on: February 13, 2023, 06:06:46 AM »
Quote
$config['smtp_helo_host'] = array(
'hostname1.com'=>'hostname1.com:465',
'hostname2.com'=>'hostname2.com:465',
'hostname3.com'=>'hostname3.com:465'
);
Here is wrong!!!
Where your RC installed ? Here must be one hostname - your RC hostname. $config['smtp_helo_host'] = 'roundcube.domain.com';

And you cannot use different settings on the same time:
Quote
$config['smtp_host'] = array(
'hostname1.com'=>'ssl://hostname1.com:465',
'hostname2.com'=>'ssl://hostname2.com:465',
'hostname3.com'=>'ssl://hostname3.com:465'
);
OR
Quote
$config['smtp_host'] = '%h';

OR

Quote
$config['smtp_host'] = 'ssl://' + '%h' + ':465';

but Not together !!!!

« Last Edit: February 13, 2023, 07:26:01 AM by Dmitry42 »

Offline Dmitry42

  • Full Member
  • ***
  • Posts: 232
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #8 on: February 13, 2023, 06:20:12 AM »
You must choose A or B or C for $config['smtp_host']:

A) $config['smtp_host'] = '%h';
    $config['smtp_helo_host'] = 'roundcube.domain.com';

B) $config['smtp_host'] = 'ssl://' + '%h' + ':465'; (not sure its correct string, but lets test it)

C) $config['smtp_host'] = array(
   'mail.domain1.com'=>'ssl://mail.domain1.com:465',
   'mail.domain2.com'=>'ssl://mail.domain2.com:465'
   );


I think C must be right way..
« Last Edit: February 13, 2023, 07:25:46 AM by Dmitry42 »

Offline georgi

  • Newbie
  • *
  • Posts: 5
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #9 on: February 13, 2023, 08:12:40 AM »
You must choose A or B or C for $config['smtp_host']:

A) $config['smtp_host'] = '%h';
    $config['smtp_helo_host'] = 'roundcube.domain.com';

B) $config['smtp_host'] = 'ssl://' + '%h' + ':465'; (not sure its correct string, but lets test it)

C) $config['smtp_host'] = array(
   'mail.domain1.com'=>'ssl://mail.domain1.com:465',
   'mail.domain2.com'=>'ssl://mail.domain2.com:465'
   );


I think C must be right way..

Yes, I figured it out as well, I was using two hostnames variables and the configuration was not ok, however, it is also not working without the helo host.

It is working perfectly, thank you for your time it is much appreciated.

Offline Dmitry42

  • Full Member
  • ***
  • Posts: 232
Re: Subdomain with custom softacolous roundcube installation with 2 servers
« Reply #10 on: February 13, 2023, 10:36:32 AM »
welcome )