Skip to content

Google Smtp-Relay Error (EHLO)聽#25716

Description

@willipreuk

How to use GitHub

  • Please use the 馃憤 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Use Google Smtp-Relay (smtp-relay.gmail.com) Service to deliver mails.

Expected behaviour

Mails are deliverd.

Actual behaviour

Expected response code 250 but got an empty response.

Server configuration

Operating system:
k8s, Docker 21.0.0RC1-fpm

Web server:
Nginx Reverse Proxy + nginx as fpm proxy

Database:
docker.io/bitnami/mariadb:10.5.8-debian-10-r21

PHP version:
7.4

Nextcloud version: (see Nextcloud admin page)
21.0.0 RC1

Updated from an older Nextcloud/ownCloud or fresh install:
Updated from v20.0.7 to the 21-rc1 but issue occurred in both versions.

Where did you install Nextcloud from:

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
  - accessibility: 1.7.0
  - activity: 2.14.3
  - admin_audit: 1.11.0
  - calendar: 2.1.3
  - cloud_federation_api: 1.4.0
  - comments: 1.11.0
  - contacts: 3.4.3
  - contactsinteraction: 1.2.0
  - dav: 1.17.1
  - external: 3.8.1
  - federatedfilesharing: 1.11.0
  - federation: 1.11.0
  - files: 1.16.0
  - files_external: 1.12.0
  - files_fulltextsearch: 20.0.0
  - files_pdfviewer: 2.1.0
  - files_rightclick: 1.0.0
  - files_sharing: 1.13.1
  - files_trashbin: 1.11.0
  - files_versions: 1.14.0
  - files_videoplayer: 1.10.0
  - firstrunwizard: 2.10.0
  - fulltextsearch: 20.0.0
  - fulltextsearch_elasticsearch: 20.0.0
  - groupfolders: 8.2.0
  - logreader: 2.6.0
  - lookup_server_connector: 1.9.0
  - mail: 1.8.1
  - nextcloud_announcements: 1.10.0
  - notifications: 2.9.0
  - oauth2: 1.9.0
  - onlyoffice: 6.2.0
  - password_policy: 1.11.0
  - photos: 1.3.0
  - privacy: 1.5.0
  - provisioning_api: 1.11.0
  - recommendations: 1.0.0
  - serverinfo: 1.11.0
  - settings: 1.3.0
  - sharebymail: 1.11.0
  - sociallogin: 4.0.3
  - support: 1.4.0
  - survey_client: 1.9.0
  - systemtags: 1.11.0
  - text: 3.2.0
  - theming: 1.12.0
  - twofactor_backupcodes: 1.10.0
  - updatenotification: 1.11.0
  - user_status: 1.1.1
  - viewer: 1.5.0
  - weather_status: 1.1.0
  - workflowengine: 2.3.0
Disabled:
  - dashboard
  - encryption
  - forms
  - ransomware_protection
  - spreed
  - user_ldap

Nextcloud configuration:

Config report
{
    "system": {
        "default_phone_region": "DE",
        "trashbin_retention_obligation": "auto, 30",
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "21.0.0.16",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "tls",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "app_install_overwrite": [
            "ocr",
            "files_lock",
            "spreed",
            "fulltextsearch",
            "fulltextsearch_elasticsearch",
            "files_fulltextsearch",
            "groupfolders",
            "onlyoffice"
        ],
        "loglevel": 2,
        "log_rotate_size": 104857600,
        "maintenance": false,
        "theme": "",
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "overwriteprotocol": "https",
        "preview_max_x": "1080",
        "preview_max_y": "1920",
        "default_language": "de",
        "defaultapp": "files"
    }
}

Are you using external storage, if yes which one: local/smb/sftp/...
local
Are you using encryption: yes/no
no
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
OpenID Connect

Client configuration

Browser:
chrome 88.0.4324.150
Operating system:
macOS 11.2.1 (20D74)

Logs

Packet Capture

Packet Capture log
SMTP 125 S: 220 smtp-relay.gmail.com ESMTP x13sm1833773pjh.14 - gsmtp
SMTP 84 C: EHLO [127.0.0.1]
SMTP 148 S: 421 4.7.0 Try again later, closing connection. (EHLO) x13sm1833773pjh.14 - gsmtp

More Info

I have found this issue on the nextcloud forum. It was postet in February 2021, here are some insights from the original poster:

So evidently either they have stopped accepting EHLO [127.0.01], or Nextcloud was previously identifying itself differently and has changed. I鈥檓 leaning toward the former but I don鈥檛 actually know what changed.
What should happen is Nextcloud should identify itself with the domain name it鈥檚 configured to send from (example.com), not [127.0.0.1]. But, I don鈥檛 know how to change this. [...]
The Nextcloud documentation mentions the ability to set advanced mail options using Swift Mailer鈥檚 streamOptions, however the site it links to does not actually have any documentation about a streamOptions parameter that I could find, and a web search of the topic didn鈥檛 return anything useful. [...]
I ran a capture on this, and smtp.gmail.com will still accept EHLO [127.0.0.1], whereas smtp-relay.gmail.com no longer does.

Activity

  1. added
    1. to developAccepted and waiting to be taken care of
    and removed
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Feb 26, 2021
  2. kesselb commented on Feb 26, 2021

    @kesselb
    Contributor

    Thanks for reporting 馃憤

    EHLO [127.0.01] is the default by Swift Mailer (the library used by Nextcloud to send emails).

    Set the name of the local domain which Swift will identify itself as.

    This should be a fully-qualified domain name and should be truly the domain
    you're using.

    If your server does not have a domain name, use the IP address. This will
    automatically be wrapped in square brackets as described in RFC 5321,
    section 4.1.3.

    https://github.com/swiftmailer/swiftmailer/blob/423b5d96ea1804dcf05436a3e34ec8dbf57b07e0/lib/classes/Swift/Transport/AbstractSmtpTransport.php#L57-L84

    protected function getSmtpInstance(): \Swift_SmtpTransport {
    $transport = new \Swift_SmtpTransport();
    $transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
    $transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1'));
    $transport->setPort($this->config->getSystemValue('mail_smtpport', 25));
    if ($this->config->getSystemValue('mail_smtpauth', false)) {
    $transport->setUsername($this->config->getSystemValue('mail_smtpname', ''));
    $transport->setPassword($this->config->getSystemValue('mail_smtppassword', ''));
    $transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN'));
    }
    $smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', '');
    if (!empty($smtpSecurity)) {
    $transport->setEncryption($smtpSecurity);
    }
    $streamingOptions = $this->config->getSystemValue('mail_smtpstreamoptions', []);
    if (is_array($streamingOptions) && !empty($streamingOptions)) {
    $transport->setStreamOptions($streamingOptions);
    }
    return $transport;
    }

    Would be the place to call setLocalDomain and set a reasonable value.

    /**
    * The return address that you want to appear on emails sent by the Nextcloud
    * server, for example ``[email protected]``, substituting your own domain,
    * of course.
    */
    'mail_domain' => 'example.com',

    Does it make sense to use the mail domain or https://www.php.net/manual/en/function.gethostname.php for ehlo?

  3. willipreuk commented on May 1, 2021

    @willipreuk
    Author

    Any updates here? Not being able to send mails through the smtp-relay is kind of a bummer...

  4. ThibaultVlacich commented on Sep 7, 2021

    @ThibaultVlacich

    Sorry for bumping a closed issue, if you want me to open a new issue, please tell me :)

    I think the implementation in #27306 is incorrect, when you have Nextcloud installed on a subdomain. For example, I have it installed on cloud.mydomain.com, and the overwrite.cli.url config is set to https://cloud.mydomain.com, so the domain that will be set in the EHLO header will be cloud.mydomain.com.

    Problem is, the Gmail SMTP relay expects the domain in the EHLO header to be mydomain.com. Imo, having a config to specify the domain of the mail would be a better solution than relying on the installation domain (which might not even match at all).

    EDIT: I opened #29011

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

    1. to developAccepted and waiting to be taken care ofbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions