Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide option to unquote localparts when normalising #168

Closed
tdelaney-leadiro opened this issue Aug 16, 2023 · 2 comments
Closed

Provide option to unquote localparts when normalising #168

tdelaney-leadiro opened this issue Aug 16, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@tdelaney-leadiro
Copy link

If a quoted localpart only contains a string that would be valid as an unquoted localpart, it would be useful to have an option to have normalisation return the localpart unquoted e.g. with the option enabled:

"test.1"@example.org would normalise to test.1@example.org
"test..1"@example.org would remain as "test..1"@example.org (because consecutive . can only appear in a quoted localpart)

The use case for this is detecting duplicate email addresses.

@tdelaney-leadiro tdelaney-leadiro added the enhancement New feature or request label Aug 16, 2023
@RohanNagar
Copy link
Owner

Hey @tdelaney-leadiro, thanks for opening this issue! This seems like a great enhancement. I will try to get to this as soon as I can.

@RohanNagar
Copy link
Owner

RohanNagar commented Sep 2, 2023

This option is now available in v1.6.0! There are two ways to configure it:

  1. Call the new normalize(boolean) method and pass in true.
  2. Set the -Djmail.normalize.strip.quotes=true JVM system property.

Example:

Email myEmail = Email.of("\"test.1\"@example.org").get();

String normalized = myEmail.normalize(true);

// normalized == "test.1@example.org"

or

System.setProperty("jmail.normalize.strip.quotes", "true");

Email myEmail = Email.of("\"test.1\"@example.org").get();

String normalized = myEmail.normalize();

// normalized == "test.1@example.org"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants