Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Offical apps | Community apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Support
  3. Relay status check always fails for Google SMTP relay (External SMTP, no auth): EHLO [127.0.0.1] and a stale password

Relay status check always fails for Google SMTP relay (External SMTP, no auth): EHLO [127.0.0.1] and a stale password

Scheduled Pinned Locked Moved Solved Support
mailnotifications
3 Posts 3 Posters 78 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ы
    Ы
    ызусеку
    wrote last edited by
    #1

    TL;DR: The daily "Email configuration error" is a false positive for relays like smtp-relay.gmail.com. The check greets the relay with EHLO [127.0.0.1] (rejected with a misleading 421 4.7.0 Try again later), and then it would fail again on a leftover password that the dashboard can't clear.

    Setup

    • Cloudron 10.1.6, Ubuntu 24.04, server hostname cloudron (no dot)
    • Mail → Smart host: External SMTP server (No authentication) → smtp-relay.gmail.com:587, STARTTLS required. The server IP is authorized in Google Workspace's SMTP relay service (IP-based, no login). Six mail domains, all configured the same way.
    • Real delivery works. Haraka logs delivered ... host=smtp-relay.gmail.com ... auth=N response="OK ...".

    What I see

    The daily check (mailStatusCheck) failed for all domains on at least 20 consecutive days:

    mailstatus: relay (example.com): Server terminates connection. response=421-4.7.0 Try again later, closing connection. (EHLO) ...
    

    The admin gets the notification and the e-mail again after every acknowledgement.

    Problem 1: the check greets the relay with EHLO [127.0.0.1]

    checkSmtpRelay() in src/mailstatus.js creates the nodemailer transport without a name option. According to the Nodemailer docs, the EHLO name defaults to the machine's hostname only if it is a fully-qualified domain name, otherwise [127.0.0.1] is sent. On a server whose hostname has no dot, Google's relay rejects that greeting:

    C: EHLO [127.0.0.1]
    S: 421-4.7.0 Try again later, closing connection. (EHLO)
    

    while the same connection with a proper name is accepted:

    C: EHLO my.example.com
    S: 250-smtp-relay.gmail.com at your service, [203.0.113.10]
    

    Google lists 421 4.7.0 as a rate-limiting response (SMTP relay docs), so the message is very misleading. The same symptom was reported for another application in this 2021 Nextcloud thread (packet capture: EHLO [127.0.0.1] → 421 4.7.0). Haraka announces the mail server FQDN, which is why real mail still works.

    getStatus() already has the FQDN (const { fqdn } = await mailServer.getLocation()) and passes it to checkMx and checkSpf, just not to checkSmtpRelay.

    Reproduction on the Cloudron host (no mail is sent):

    cd /home/yellowtent/box && /usr/local/node-*/bin/node -e "
    const nm = require('nodemailer');
    (async () => {
      for (const name of ['[127.0.0.1]', 'my.example.com']) {   // use your mail server FQDN
        const tr = nm.createTransport({ host: 'smtp-relay.gmail.com', port: 587, secure: false, requireTLS: true, connectionTimeout: 5000, greetingTimeout: 5000, name });
        try { await tr.verify(); console.log('EHLO ' + name + ' -> OK'); }
        catch (e) { console.log('EHLO ' + name + ' -> FAIL: ' + e.message.split('\n')[0]); }
        tr.close();
      }
    })();"
    

    Output:

    EHLO [127.0.0.1] -> FAIL: Server terminates connection. response=421-4.7.0 Try again later, closing connection. (EHLO)
    EHLO my.example.com -> OK
    

    Problem 2: a stale password makes the check attempt SMTP AUTH with an empty username

    For external-smtp-noauth the check still does:

    if (relay.username || relay.password) {
        options.auth = { user: relay.username, pass: relay.password };
    }
    

    My relay configs have an empty username but a leftover non-empty password (probably from an earlier authenticated setup). As soon as the EHLO problem is fixed, the check fails with Missing credentials for "PLAIN", because Google advertises AUTH after STARTTLS. Haraka is not affected: in the mail container, haraka.js uses auth_type = relay.username ? 'plain' : ''.

    The stale password can't be removed from the dashboard:

    • The External SMTP server (No authentication) form has no username/password fields. SmartHostSettingsItem.vue loads the stored password into the hidden field, re-submits it, and never sends an empty password.
    • When the provider is switched, the mail service's setDomainRelay() (domains.js) merges the previously stored username/password back into the new relay whenever the request body lacks those keys.

    Only an API call with an explicit "password": "" clears it.

    Suggested changes

    1. Pass the mail FQDN as the EHLO name in the relay check:
    -async function checkSmtpRelay(relay) {
    +async function checkSmtpRelay(relay, fqdn) {
     ...
         const options = {
             connectionTimeout: 5000,
             greetingTimeout: 5000,
    +        name: fqdn, // otherwise nodemailer greets with [127.0.0.1] when os.hostname() is not an FQDN
             host: relay.host,
     ...
    -        { what: 'relay', promise: checkSmtpRelay(mailDomain.relay) }
    +        { what: 'relay', promise: checkSmtpRelay(mailDomain.relay, fqdn) }
    
    1. In the check, set auth only when a username exists (the same rule Haraka uses), e.g. if (relay.username) options.auth = {...}, or skip auth for external-smtp-noauth.
    2. Optionally, drop the stored username/password when saving a provider that doesn't use them, so stale credentials can't linger unnoticed.

    Workaround (verified)

    1. Give the server an FQDN hostname, e.g. hostnamectl set-hostname my.example.com. It is picked up immediately, since nodemailer calls os.hostname() for each new connection.
    2. Clear the stale password through the API with a write-enabled token. Send all fields (keep your own values for host, port and flags), because only username/password are merged from the stored config:
    curl -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
      -d '{"provider":"external-smtp-noauth","host":"smtp-relay.gmail.com","port":587,"username":"","password":"","acceptSelfSignedCerts":false,"requireTLS":true,"forceFromAddress":false}' \
      https://my.example.com/api/v1/mail/example.com/relay
    

    After both steps the relay check passes for all domains.

    Thanks!

    1 Reply Last reply
    2
    • jamesJ
      jamesJ
      james
      Staff
      wrote last edited by
      #2

      Hello @ызусеку and welcome to the Cloudron community forum

      1 Reply Last reply
      1
      • girishG
        girishG
        girish
        Staff
        wrote last edited by
        #3

        Thanks, i have applied the fix!

        1 Reply Last reply
        1
        • girishG girish has marked this topic as solved

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Bookmarks
        • Search