Skip to content

SMTP Authentication fails with "501 Syntactically invalid HELO argument(s)" #14941

Description

@alexhalbi

Steps to reproduce

It seems my Nextcloud installation sends EHLO _ and then HELO _ which is not accepted by my mailserver. It happens with every possible configuration combination (via SMTP) with the mailserver of my Provider smtp.world4you.com.

Expected behaviour

Nextcloud should send the FQDN instead of the underscore.

Actual behaviour

When Testing the Mail Connection it sends a underscore right after the HELO command which is not accepted by my Mailserver since it is invalid behaviour.
http://www.samlogic.net/articles/smtp-commands-reference.htm

When connecting to my actual Mailserver I get following Error with any Mail Address combination:

(Fehler: Expected response code 250 but got code "501", with message "501 Syntactically invalid HELO argument(s) ")

I tested the behaviour by running a Netcat listener locally and trying to connect to it instead of the Mailserver to retrive the commands sent by Nextcloud. This is the full output:

~# nc -nvlp 25
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Listening on :::25
Ncat: Listening on 0.0.0.0:25
Ncat: Connection from 192.168.X.Y.
Ncat: Connection from 192.168.X.Y:55132.
220 localhost Wed, 03 Apr 2019 12:33:20 +0200
EHLO _
250 Succ
MAIL FROM:<[email protected]>
250  
RCPT TO:<[email protected]>
250  
DATA
250  
QUIT
250 

Server configuration

I am using this Docker Image in Unraid:
https://forums.unraid.net/topic/48383-support-linuxserverio-nextcloud/
Operating system: Docker

Web server:

I am using a Letsencrypt Docker with nginx running as a reverse proxy to get a certificate.
Nextcloud runs on the docker in nginx Version: nginx version: nginx/1.14.2

Database: MariaDB

PHP version:

PHP 7.2.14 (cli) (built: Jan 12 2019 20:59:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.14, Copyright (c) 1999-2018, by Zend Technologies

Nextcloud version: Nextcloud 15.0.5

Updated from an older Nextcloud/ownCloud or fresh install: fresh install a few weeks ago, but it did not work back then either.

Where did you install Nextcloud from: https://forums.unraid.net/topic/48383-support-linuxserverio-nextcloud/

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - accessibility: 1.1.0
  - activity: 2.8.2
  - apporder: 0.6.0
  - bruteforcesettings: 1.3.0
  - calendar: 1.6.4
  - circles: 0.16.2
  - cloud_federation_api: 0.1.0
  - comments: 1.5.0
  - contacts: 3.0.5
  - dav: 1.8.1
  - federatedfilesharing: 1.5.0
  - federation: 1.5.0
  - files: 1.10.0
  - files_pdfviewer: 1.4.0
  - files_sharing: 1.7.0
  - files_texteditor: 2.7.0
  - files_trashbin: 1.5.0
  - files_versions: 1.8.0
  - files_videoplayer: 1.4.0
  - firstrunwizard: 2.4.0
  - gallery: 18.2.0
  - logreader: 2.0.0
  - lookup_server_connector: 1.3.0
  - nextcloud_announcements: 1.4.0
  - notifications: 2.3.0
  - oauth2: 1.3.0
  - password_policy: 1.5.0
  - provisioning_api: 1.5.0
  - serverinfo: 1.5.0
  - sharebymail: 1.5.0
  - support: 1.0.0
  - survey_client: 1.3.0
  - systemtags: 1.5.0
  - theming: 1.6.0
  - twofactor_backupcodes: 1.4.1
  - updatenotification: 1.5.0
  - workflowengine: 1.5.0
Disabled:
  - admin_audit
  - encryption
  - files_external
  - user_ldap

Are you using external storage, if yes which one: no

Are you using encryption: no

Are you using an external user-backend, if yes which one: no

Client configuration

Browser: Chrome

Operating system: Windows 10

Logs

Web server error log

Web server error log

Nothing in /var/log/nginx/error.log.

Nextcloud log (data/nextcloud.log)

Nextcloud log These are Logs associated with Mail but I do not think they a realated to the issue.
{"reqId":"FC0TigB7PrvGlNeEYV6D","level":3,"time":"2019-04-03T10:37:51+00:00","remoteAddr":"192.168.X.Y","user":"user","app":"PHP","method":"POST","url":"\/settings\/admin\/mailtest","message":"Uninitialized string offset: 3 at \/config\/www\/nextcloud\/3rdparty\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/AbstractSmtpTransport.php#469","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/73.0.3683.86 Safari\/537.36","version":"15.0.5.3"}
{"reqId":"4Up3yTIhBavWrO9UxXNv","level":3,"time":"2019-04-03T10:49:32+00:00","remoteAddr":"192.168.X.Y","user":"user","app":"PHP","method":"POST","url":"\/settings\/admin\/mailtest","message":"Uninitialized string offset: 3 at \/config\/www\/nextcloud\/3rdparty\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/AbstractSmtpTransport.php#469","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/73.0.3683.86 Safari\/537.36","version":"15.0.5.3"}

Activity

  1. violoncelloCH commented on Apr 18, 2019

    @violoncelloCH
    Member

    cc @nextcloud/server-triage

  2. kesselb commented on Apr 19, 2019

    @kesselb
    Contributor
    'loglevel' => 0,
    'mail_smtpdebug' => true,
    

    Should generate some usefull output for your case.

    [core] Debug: ++ Starting Swift_SmtpTransport
    << 220 mailhog.example ESMTP MailHog
    
    >> EHLO nextcloud.test
    
    << 250-Hello nextcloud.test
    250-PIPELINING
    250 AUTH PLAIN
    
    ++ Swift_SmtpTransport started
    >> MAIL FROM:<[email protected]>
    
    >> RCPT TO:<[email protected]>
    
    >> DATA
    
    << 250 Sender [email protected] ok
    
    << 250 Recipient [email protected] ok
    
    << 354 End data with <CR><LF>.<CR><LF>
    
    >> 
    .
    
    << 250 Ok: queued as [email protected]
    
    
    POST /settings/admin/mailtest
    from 192.168.10.1 by admin at 2019-04-19T10:53:37+00:00
    
  3. alexhalbi commented on Apr 27, 2019

    @alexhalbi
    Author

    Hello,
    I just changed the settings and got the same EHLO statement which I already found via my dummy smtp server, when using my real smtp server.

    Beim Senden der E-Mail ist ein Problem aufgetreten. Bitte überprüfen Sie Ihre Einstellungen. (Fehler: Expected response code 250 but got code "501", with message "501 Syntactically invalid HELO argument(s)
    "
    Log data:
    ++ Starting Swift_SmtpTransport
    << 220 mx14lb.world4you.com ESMTP Exim 4.91 Sat, 27 Apr 2019 11:11:02 +0200
    
    >> EHLO _
    
    << 501 Syntactically invalid EHLO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    " (code: 501)
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    "
    Log data:
    ++ Starting Swift_SmtpTransport
    << 220 mx14lb.world4you.com ESMTP Exim 4.91 Sat, 27 Apr 2019 11:11:02 +0200
    
    >> EHLO _
    
    << 501 Syntactically invalid EHLO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    " (code: 501) (code: 501)
    >> HELO _
    
    << 501 Syntactically invalid HELO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid HELO argument(s)
    " (code: 501)
    Log data:
    ++ Starting Swift_SmtpTransport
    << 220 mx14lb.world4you.com ESMTP Exim 4.91 Sat, 27 Apr 2019 11:11:02 +0200
    
    >> EHLO _
    
    << 501 Syntactically invalid EHLO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    " (code: 501)
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    "
    Log data:
    ++ Starting Swift_SmtpTransport
    << 220 mx14lb.world4you.com ESMTP Exim 4.91 Sat, 27 Apr 2019 11:11:02 +0200
    
    >> EHLO _
    
    << 501 Syntactically invalid EHLO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    " (code: 501) (code: 501)
    >> HELO _
    
    << 501 Syntactically invalid HELO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid HELO argument(s)
    " (code: 501)
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid HELO argument(s)
    "
    Log data:
    ++ Starting Swift_SmtpTransport
    << 220 mx14lb.world4you.com ESMTP Exim 4.91 Sat, 27 Apr 2019 11:11:02 +0200
    
    >> EHLO _
    
    << 501 Syntactically invalid EHLO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    " (code: 501)
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    "
    Log data:
    ++ Starting Swift_SmtpTransport
    << 220 mx14lb.world4you.com ESMTP Exim 4.91 Sat, 27 Apr 2019 11:11:02 +0200
    
    >> EHLO _
    
    << 501 Syntactically invalid EHLO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid EHLO argument(s)
    " (code: 501) (code: 501)
    >> HELO _
    
    << 501 Syntactically invalid HELO argument(s)
    
    !! Expected response code 250 but got code "501", with message "501 Syntactically invalid HELO argument(s)
    " (code: 501) (code: 501))
    
  4. kesselb commented on Apr 27, 2019

    @kesselb
    Contributor

    Could you share the mail settings?

  5. alexhalbi commented on Apr 27, 2019

    @alexhalbi
    Author

    Yes sure, since this issue is before even account information is sent, you can enter any account information you like, I already tested that.
    The sendmode is SMTP, no encryption, authentificationmethod clear, server smtp.world4you.com, port 25

    I am using nextcloud in a docker on unraid like stated in the first post and the issue persists on Nextcloud 15.0.7 which I just updated to.

  6. kesselb commented on Apr 27, 2019

    @kesselb
    Contributor
  7. alexhalbi commented on Apr 27, 2019

    @alexhalbi
    Author

    yes I did
    But it has a different domain than the server.

  8. kesselb commented on Apr 27, 2019

    @kesselb
    Contributor

    https://github.com/swiftmailer/swiftmailer/blob/84c35980c585d9784d79aa1a22ad174f3bfa727c/lib/dependency_maps/transport_deps.php#L4-L8

    Code above is used to determinate the localdomain which is used as ehlo. Not sure if this is related to nextcloud. We relay on swiftmailer here.

  9. alexhalbi commented on Apr 27, 2019

    @alexhalbi
    Author
  10. alexhalbi commented on Apr 29, 2019

    @alexhalbi
    Author

    Okay if I replace the code in swiftmailer you referenced to the following, to always send '127.0.0.1' the test-mail gets sent succesfully.

    ->asValue('127.0.0.1')

    The question is, if this is a swiftmailer bug or a Nextcloud bug? Actually I do not know where Swiftmailer gets $_SERVER['SERVER_NAME'] from, but I am sure it is _ which is not cought by the regex and therefore sent with the EHLO statement. https://www.phpliveregex.com/p/rSF#tab-preg-replace

  11. kesselb commented on Apr 29, 2019

    @kesselb
    Contributor
  12. alexhalbi commented on Apr 29, 2019

    @alexhalbi
    Author

    Thanks for the link, if I use the original swiftmailer file and replace the server_name _ in the nginx configuration in my docker container to server_name my.domain sending e-mails works fine.

    What about building a workaround to not pass an underline to swiftmailer when the default catch all block of nginx is used? I think that would be better than changing the config, since now I am unable to get to my nextcloud instance, when using the IP adress instead of the domain name.


    On my Docker container the file is located at /config/nginx/site-confs/default

  13. kesselb commented on May 2, 2019

    @kesselb
    Contributor

    This logic is part of swiftmailer not nextcloud. I would classify this as configuration problem and close it @MorrisJobke 🏓

  14. szaimen commented on May 20, 2021

    @szaimen
    Contributor

    I'm closing this issue due to inactivity. If this is still happening please make sure to upgrade to the latest version. After that, feel free to reopen.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions