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

Email Validation is not RFC5321 compliant #986

Open
jayesbe opened this issue Jun 25, 2020 · 7 comments
Open

Email Validation is not RFC5321 compliant #986

jayesbe opened this issue Jun 25, 2020 · 7 comments
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@jayesbe
Copy link

jayesbe commented Jun 25, 2020

Issue Summary

Email addresses where the local part end in a period are being flagged as invalid even though they are RFC5321 compliant.

This comment from seven years ago defines the issue fairly well

https://www.php.net/manual/pt_BR/function.filter-var.php#112492

Copying here to make it easier.

I found some addresses that FILTER_VALIDATE_EMAIL rejects, but RFC5321 permits:

<?php
foreach (array(
        '[email protected]',
        '(comment)[email protected]',
        '"this is v@lid!"@example.com',
        '"much.more unusual"@example.com',
        'postbox@com',
        'admin@mailserver1',
        '"()<>[]:,;@\\"\\\\!#$%&\'*+-/=?^_`{}| ~.a"@example.org',
        '" "@example.org',
    ) as $address) {
    echo "<p>$address is <b>".(filter_var($address, FILTER_VALIDATE_EMAIL) ? '' : 'not')." valid</b></p>";
}
?>

Results:

  • [email protected] is not valid
  • (comment)[email protected] is not valid
  • "this is v@lid!"@example.com is not valid
  • "much.more unusual"@example.com is not valid
  • postbox@com is not valid
  • admin@mailserver1 is not valid
  • "()<>[]:,;@"\!#$%&'*+-/=?^_`{}| ~.a"@example.org is not valid
  • " "@example.org is not valid

The documentation does not saying that FILTER_VALIDATE_EMAIL should pass the RFC5321, however you can meet with these examples (especially with the first one). So this is a note, not a bug report.

Technical details:

sendgrid/php-http-client 3.10.7
sendgrid/sendgrid 7.6.0 using PHP.

So the issue is we have users in our system that do have email addresses where the localpart ends in a period. This email address is being flagged as invalid even though it should be perfectly find to send an email to.

I guess the question is, does sendgrid support the above email addresses that are valid according RFC5321 ?

@thinkingserious
Copy link
Contributor

Hello @jayesbe,

With respect to the behavior of FILTER_VALIDATE_EMAIL, assuming we support sending emails in one or more of the results you provided, would you propose the implementation of an alternative filter (likely within setEmailAddress) that better conforms to RFC521? If so, I will re-title and add this issue to our internal backlog to be prioritized.

For "does sendgrid support the above email addresses that are valid according RFC5321?", I would suggest reaching out to our support team.

With best regards,

Elmer

@jayesbe
Copy link
Author

jayesbe commented Jun 26, 2020

@thinkingserious this is the best I can do in my research.. from the author of the filter_var regex implementation himself.

https://stackoverflow.com/a/28770784

https://stackoverflow.com/questions/28280176/php-filter-var-and-rfc-5322

@thinkingserious
Copy link
Contributor

@jayesbe,

Thanks for the research and links!

For a short term fix, have you tried bypassing the email validation filter for the emails that are failing?

Syncing our internal validation at the API level with the appropriate filtering seems to be the long term fix.

@thinkingserious thinkingserious added status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library labels Jun 26, 2020
@thinkingserious
Copy link
Contributor

Just checking in to find out if you have implemented the short term fix and your thoughts on the long term fix. Thanks!

@eshanholtz
Copy link
Contributor

I'm adding this feature request to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

@eshanholtz eshanholtz added type: community enhancement feature request not on Twilio's roadmap status: help wanted requesting help from the community and removed status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library labels Aug 7, 2020
@esetnik
Copy link

esetnik commented Nov 1, 2020

I just hit the same issue with a user trying to sign up for our service with an email like test.o’[email protected]

@WebMago
Copy link

WebMago commented Oct 26, 2021

I have same issue with an [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

5 participants