Skip to content

Conversation

@Montana
Copy link

@Montana Montana commented Jun 5, 2025

Validating email format before processing.

Validating email format before processing.
@Saritus
Copy link

Saritus commented Jun 6, 2025

While the new regex ^[^@\s]+@[^@\s]+\.[^@\s]+$ catches basic email formatting issues, it doesn't cover many valid edge cases defined in the RFC 5322 spec. For example, it allows invalid domains like @.com and fails to catch some invalid placements of dots, but disallows valid quoted local parts ("john.doe"@example.com), local parts with special characters (user+mailbox@example.com), or IP address literals (user@[192.168.1.1]).

For more robust validation, I recommend using one of the well-established regex patterns shared by emailregex.com.
You can also find a much more in-depth discussion of the topic of email validation using regex at regular-expressions.info.

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.

2 participants