|Subject:||Your class stays in conflict with...|
|Summary:||Package rating comment|
Matthias Kaschubowski rated this package as follows:
|Utility: ||Not sure|
|Consistency: ||Not sure|
Matthias Kaschubowski - 2016-04-24 13:44:01
Your class stays in conflict with the Single Responsibility Principle. It also prevents IDN-domains from being validated. So, your class will automatically invalidate many many valid email addresses.
I recommend to use filter_var and a IDN transport for email validation.
Manuel Lemos - 2016-04-24 20:18:55 - In reply to message 1 from Matthias Kaschubowski
The purpose of the class is to perform several levels of email validation. I believe it is still a single responsibility.
As for IDN I have not came across one example. Can you provide an example?
I suspect that is a matter of adjusting the validation regular expression, which is a class configuration parameter.
Matthias Kaschubowski - 2016-04-24 22:18:26 - In reply to message 2 from Manuel Lemos
Manuel Lemos - 2016-05-03 22:38:36 - In reply to message 3 from Matthias Kaschubowski
I tested here with Thunderbird and it seems email addresses like that need to be encoded as UTF-8, so the regular expression would validate it if I included higher 8 bit characters.
Ian - 2017-12-28 15:07:25 - In reply to message 4 from Manuel Lemos
No, they need to be encoded as ascii.
Unfortunately, idn-to-ascii does not exist in most typical PHP installs so you'll want to provide a class like you do with getmxrr.
Manuel Lemos - 2017-12-28 21:24:44 - In reply to message 5 from Ian
I am not sure what you mean? Do you mean the class validate addresses with unicode characters? Can you give me an example?
Ian - 2017-12-28 23:37:03 - In reply to message 6 from Manuel Lemos
Sure, take example of teßt@düsseldorf.de
It will not pass your regex and getmxrr will not work with "düsseldorf.de." (note good practise to use final dot for fqdn)
You can change your regex to allow it, but getmxrr will still fail.
You must convert to Punycode representation in ASCII:
teßt@düsseldorf.de -> firstname.lastname@example.org
Now "email@example.com" will pass the unmodified regex and it will work correctly with getmxrr.
I tested all of this :-)
The issue, as I mentioned, is how best to do the conversion when function_exists('idn_to_ascii') fails on most systems. This will do it: