RocketChat / RocketChat/Rocket.Chat

Google SMTP returning intermittent 421 4.7.0 errors

Open
#38,508 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

valid
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Context:

  • Self-hosted on EC2
  • Docker compose deployment

SMTP setup was completed using Google smtp-relay. Test emails were succesfully sent.

However, when adding new users, intermittently Google would close the connection prior to HELO with a 421 4.7.0 code. Therefore, these emails were never sent. Users couldn't log in.

Upon investigation:
Nodemailer uses os.hostname() for the SMTP EHLO greeting. In Docker containers, this returns the container ID (e.g., e508959023b2) instead of a valid FQDN. Google's SMTP relay rejects non-FQDN hostnames in EHLO, but inconsistently - causing intermittent failures.
Workaround:
Set hostname: your.domain.com in Docker Compose for the Rocket.Chat container.
Suggested Fix:
Expose nodemailer's name option in Rocket.Chat's SMTP settings (Admin → Email → SMTP). This option sets the EHLO hostname explicitly, independent of the container's system hostname.
References:
Nodemailer name option: https://nodemailer.com/smtp/ ("optional hostname of the client, used for identifying to the server")
Similar issue in other frameworks: https://github.com/loco-rs/loco/issues/1055

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Admin → Email → SMTP settings entry point and inspect the Nodemailer SMTP integration described in the issue. Trace how SMTP options are stored and passed to the mailer, then verify that the configured client hostname is used for the EHLO greeting. Done means Docker deployments can set this value and Google SMTP relay no longer rejects the connection because of the container hostname.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, typescript
Domain
backend, networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.