Skip to content

More strict email address parsing (to match nodemailer) - #914

Open
ignatiusm wants to merge 2 commits into
devfrom
909-fix-smtp-error
Open

More strict email address parsing (to match nodemailer)#914
ignatiusm wants to merge 2 commits into
devfrom
909-fix-smtp-error

Conversation

@ignatiusm

@ignatiusm ignatiusm commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Resolves #909

From a slack discussion internally:

"Now looking at this code, I can't see how it possibly worked in the past!! As per the screenshot below, the HOSTNAME would include http:// which isn't a valid domain. My only idea was that maybe a library changed which enforced a more strict parsing.

I was hunting though our package.json and yarn.lock for libraries that might have changed, but our smtp is provided by Ethereal in dev and: checkout their fancy new updated website: https://ethereal.email/ and there is a new update to nodemailer from July 29th with changes that mean that it isn't silently dropping special characters anymore (see second screenshot).

Anyway, I think this is super interesting and am pleased it isn't anything to do with us. I guess the moral of the story is to not rely on special behaviour and try to provide the most specific data whereever possible"

Adds a test to verify the error, and a fix.

@ignatiusm
ignatiusm changed the base branch from main to dev August 4, 2026 04:17

@iamtanuj18 iamtanuj18 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks clean and tests cover the paths that matter.

Small hypothetical worth noting: the if branch handles HOSTNAME with http/https prefix nicely via URL parsing. The else branch takes HOSTNAME as-is though, so if someone ever sets HOSTNAME as localhost:5173 (with port, no protocol prefix, via hand-editing .env), it'd still include the port in the from-address and probably fail. Unlikely since .env.example has the protocol and prod uses plain domains, but a defensive port-strip in the else would cover it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SMTP error when sending emails in Dev

3 participants