sendgrid-php
sendgrid-php copied to clipboard
Email Validation is not RFC5321 compliant
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 ?