Skip to content

Google SMTP returning intermittent 421 4.7.0 errors #38508

@S1m

Description

@S1m

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: loco-rs/loco#1055

Metadata

Metadata

Assignees

No one assigned

    Labels

    contrib: validA valid contribution where maintainers will review based on priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions