postmark-php icon indicating copy to clipboard operation
postmark-php copied to clipboard

email validation function _validateAddress now fails on new style tlds

Open harrybailey opened this issue 9 years ago • 3 comments

Big fat warning for anyone still making use of this or considering using it.

The email validation function _validateAddress has a specific length check for the final part tld of the domain. It's limited to 6 characters.

Enter such domains as .academy (7 characters) and watch the invalid email exceptions fly.

harrybailey avatar Feb 29 '16 09:02 harrybailey

Well, 4 years later... does anyone have a solution to this?

alphex avatar Jun 23 '20 16:06 alphex

how good is anyones regex?

+[a-z]{2,6})|

in this line of code

		$regex = "/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i";

Would that be the fix, changing the 6 to say? 20?

alphex avatar Jun 23 '20 16:06 alphex

Try to replace it with filter_var. If it works, PRs are welcome :)

https://www.php.net/manual/en/filter.examples.validation.php

Znarkus avatar Jun 23 '20 18:06 Znarkus