Znarkus / postmark-php

Postmark PHP class
http://developer.postmarkapp.com/developer-libs.html#php-5
139 stars 49 forks source link

email validation function _validateAddress now fails on new style tlds #30

Open harrybailey opened 8 years ago

harrybailey commented 8 years ago

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.

alphex commented 4 years ago

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

alphex commented 4 years ago

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?

Znarkus commented 4 years ago

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

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