Roundcube Community Forum

Release Support => Release Discussion => Topic started by: mcnesium on May 12, 2020, 11:27:41 AM

Title: SMTP Error (554): Sending to remote addresses (relaying) is not allowed.
Post by: mcnesium on May 12, 2020, 11:27:41 AM
I am trying to run Roundcube Webmail 1.4.4 in a Docker environment (see here for Dockerfile etc. (https://gitea.com/mcnesium/docker-roundcube)) with the identity-smtp (https://plugins.roundcube.net/packages/elm/identity_smtp) plugin, which allows me to also send mail from multiple mail accounts (identities).

Problem: sending mails does only work for recipients whose domain name is also handled by the same SMTP-server that I am trying to send mail to. For any other recipient, the following error message appears:

> SMTP Error (554): Failed to add recipient "mail@recipient.tld" (Refused. Sending to remote addresses (relaying) is not allowed.)

I am not sure whether that is a configuration error or a bug within one of the components. For the plugin I already asked here (https://github.com/deflomu/Roundcube-SMTP-per-Identity-Plugin/issues/19), but no response there. In another non-dockerized setup and Roundcube Webmail 1.3.10 this plugin is included and works very well. So either this is an issue with v1.4.x or a configuration error.

How can I fix this? Any help?
Title: Re: SMTP Error (554): Sending to remote addresses (relaying) is not allowed.
Post by: JohnDoh on May 13, 2020, 11:02:57 AM
Check the SMTP settings in your RC config, specifically smtp_user and smtp_pass. That error could me that you do not have SMTP auth enabled and you need it to send external mail.
Title: Re: SMTP Error (554): Sending to remote addresses (relaying) is not allowed.
Post by: mcnesium on May 18, 2020, 07:37:47 AM
Thank you for your reply. What exactly do you mean by "Check the SMTP settings"? Here is what they look like:

Code: [Select]
$ docker-compose exec roundcube cat config/config.inc.php
<?php
    $config
['db_dsnw'] = 'mysql://roundcube:xxxxxxxx@db:3306/roundcube';
    
$config['db_dsnr'] = '';
    
$config['default_host'] = 'ssl://imap.example.org';
    
$config['default_port'] = '993';
    
$config['des_key'] = 'xxxxxxxxxxxx';
    
$config['temp_dir'] = '/tmp/roundcube-temp';
    
$config['plugins'] = ['archive''zipdownload''enigma''jqueryui''managesieve''markasjunk''identity_smtp''carddav''contextmenu'];
    
$config['zipdownload_selection'] = true;
    
$config['log_driver'] = 'stdout';
    
$config['skin'] = 'elastic';
    
$config['smtp_server'] = 'xyz.uberspace.de';
    
$config['smtp_port'] = '587';
    
$config['smtp_user'] = 'abc@xyz.uberspace.de';
    
$config['smtp_pass'] = 'xxxxxxxx';

I added smtp_user and smtp_pass settings manually to the config file in the container, because they are not being added here (https://github.com/roundcube/roundcubemail-docker/blob/master/apache/docker-entrypoint.sh#L72-L86) (I might send a PR on that later) – then logged out and back in, all that.

But what is the matter with default SMTP settings anyway? Individual SMTP settings for each identity is exactly what the identity_smtp plugin (https://plugins.roundcube.net/packages/elm/identity_smtp) is for, so the default SMTP settings of my RC should not matter at all, or is that a wrong assumption?
Title: Re: SMTP Error (554): Sending to remote addresses (relaying) is not allowed.
Post by: mcnesium on May 18, 2020, 09:57:22 AM
I added  $config['smtp_debug'] = true; to the config. The output doesn't seem to include much better information about what is wrong:

Here is the output for sending a mail to an account that uses the same SMTP:

Quote
    smtp: <7cc5f104> Connecting to tls://schedar.uberspace.de:587...
    smtp: <7cc5f104> Recv: 220 schedar.uberspace.de ESMTP
    smtp: <7cc5f104> Send: EHLO webmail.mydomain.de
    smtp: <7cc5f104> Recv: 250-schedar.uberspace.de
    smtp: <7cc5f104> Recv: 250-STARTTLS
    smtp: <7cc5f104> Recv: 250-PIPELINING
    smtp: <7cc5f104> Recv: 250-8BITMIME
    smtp: <7cc5f104> Recv: 250 AUTH LOGIN PLAIN
    smtp: <7cc5f104> Send: MAIL FROM:<mail@mydomain.de>
    smtp: <7cc5f104> Recv: 250 ok
    smtp: <7cc5f104> Send: RCPT TO:<qwer@mydomain.de>
    smtp: <7cc5f104> Recv: 250 ok
    smtp: <7cc5f104> Send: DATA
    smtp: <7cc5f104> Recv: 354 Proceed.
    …

And here is the output when sending to some other receipient on a different mail server:

Quote
    smtp: <7cc5f104> Connecting to tls://schedar.uberspace.de:587...
    smtp: <7cc5f104> Recv: 220 schedar.uberspace.de ESMTP
    smtp: <7cc5f104> Send: EHLO webmail.mydomain.de
    smtp: <7cc5f104> Recv: 250-schedar.uberspace.de
    smtp: <7cc5f104> Recv: 250-STARTTLS
    smtp: <7cc5f104> Recv: 250-PIPELINING
    smtp: <7cc5f104> Recv: 250-8BITMIME
    smtp: <7cc5f104> Recv: 250 AUTH LOGIN PLAIN
    smtp: <7cc5f104> Send: MAIL FROM:<mail@mydomain.de>
    smtp: <7cc5f104> Recv: 250 ok
    smtp: <7cc5f104> Send: RCPT TO:<mail@otherdomain.com>
    smtp: <7cc5f104> Recv: 554 Refused. Sending to remote addresses (relaying) is not allowed.
    errors: <7cc5f104> PHP Error: Invalid response code received from server (POST /?_task=mail&_unlock=loading1589809230866&_framed=1&_lang=en_US&_action=send)
    smtp: <7cc5f104> Send: RSET
    smtp: <7cc5f104> Recv: 250 flushed
    errors: <7cc5f104> SMTP Error: Failed to add recipient 'mail@otherdomain.com'. Refused. Sending to remote addresses (relaying) is not allowed. (Code: 554) in /var/www/html/program/lib/Roundcube/rcube.php on line 1702 (POST /?_task=mail&_unlock=loading1589809230866&_framed=1&_lang=en_US&_action=send)
    smtp: <7cc5f104> Send: QUIT
    smtp: <7cc5f104> Recv: 221 schedar.uberspace.de172.21.0.1 - - [18/May/2020:13:40:31 +0000] "POST /?_task=mail&_unlock=loading1589809230866&_framed=1&_lang=en_US HTTP/1.1" 200 956 "https://webmail.mydomain.de/?_task=mail&_action=compose&_id=15772262815ec29043a5049" "Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0"

Is that output more helpful?
Title: Re: SMTP Error (554): Sending to remote addresses (relaying) is not allowed.
Post by: JohnDoh on May 19, 2020, 12:02:03 PM
Quote
I added smtp_user and smtp_pass settings manually to the config file in the container, because they are not being added here (I might send a PR on that later) – then logged out and back in, all that.
If you have a installation and you are using 1.4 then smtp auth is enabled by default so that is probably why they are not included in the config file.

Quote
But what is the matter with default SMTP settings anyway?
That is what we are trying to figure out isn't it? You said it works fine with other clients right?

Quote
Individual SMTP settings for each identity is exactly what the identity_smtp plugin is for, so the default SMTP settings of my RC should not matter at all, or is that a wrong assumption?
I dont know anything about that plugin. If I were you I'd disable all plugins while trying to solve the issue in case it is being caused by one of them.
Title: Re: SMTP Error (554): Sending to remote addresses (relaying) is not allowed.
Post by: mcnesium on June 05, 2020, 08:08:03 AM
As I already wrote here (https://github.com/deflomu/Roundcube-SMTP-per-Identity-Plugin/issues/19#issuecomment-633496117), I was able to break down the problem to the encryption of the passwords.

Before storing the SMTP passwords to the database, they are being encrypted here:

Code: [Select]
            $password = rcmail::get_instance()->encrypt($password);
When sending a mail, the passwords are being decrypted here:
Code: [Select]
            $args['smtp_pass']   = rcmail::get_instance()->decrypt($smtpSettings['smtp_pass']);
I disabled both the encryption and decryption, and now the plugin works again, with the downside that the passwords are unencrypted in the database.

Do you have an idea how to fix the password encryption?

Also: sorry for late reply. I must have missed the reply notification.
Title: Re: SMTP Error (554): Sending to remote addresses (relaying) is not allowed.
Post by: GayuS on August 17, 2020, 09:21:07 AM
I was facing same issue.That was explained well.