Relay status check always fails for Google SMTP relay (External SMTP, no auth): EHLO [127.0.0.1] and a stale password
-
TL;DR: The daily "Email configuration error" is a false positive for relays like
smtp-relay.gmail.com. The check greets the relay withEHLO [127.0.0.1](rejected with a misleading421 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()insrc/mailstatus.jscreates the nodemailer transport without anameoption. 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 tocheckMxandcheckSpf, just not tocheckSmtpRelay.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 -> OKProblem 2: a stale password makes the check attempt SMTP AUTH with an empty username
For
external-smtp-noauththe 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.jsusesauth_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.vueloads 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 storedusername/passwordback into the new relay whenever the request body lacks those keys.
Only an API call with an explicit
"password": ""clears it.Suggested changes
- 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) }- In the check, set
authonly when a username exists (the same rule Haraka uses), e.g.if (relay.username) options.auth = {...}, or skipauthforexternal-smtp-noauth. - Optionally, drop the stored username/password when saving a provider that doesn't use them, so stale credentials can't linger unnoticed.
Workaround (verified)
- Give the server an FQDN hostname, e.g.
hostnamectl set-hostname my.example.com. It is picked up immediately, since nodemailer callsos.hostname()for each new connection. - 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/relayAfter both steps the relay check passes for all domains.
Thanks!
- Cloudron 10.1.6, Ubuntu 24.04, server hostname
-
-
-
G 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