MattKetmo/EmailChecker

Cannot be used with International email addresses

Opened this issue · 0 comments

Hi there, thanks for the project, it's pretty handy!

Unfortunately, because of how the isValid function is implemented this library cannot be utilized with international domains and will always report them as invalid.

Problem

This isn't really your fault, but rather due to PHP itself as FILTER_VALIDATE_EMAIL will not validate them correctly.
(If you want some valid emails to test, there's a few examples on Wikipedia)

filter_var($email, FILTER_VALIDATE_EMAIL)

Proposed Solution

Ideally, this library should provide a method to disable the built-in validation which would allow someone to use packages such as egulias/EmailValidator which is much better than PHP's implementation and will correctly validate these domains. Otherwise people will be left to implement workarounds to be able to utilize it when they also need to handle international email addresses.

Your parseEmailAddress function already appears to correctly handle them, so the only road block is just giving the option to disable validation check.

Workaround

For anyone else who runs into this limitation, you can actually pretty easily bypass things just replicating what the isValid function does.
Here's an example from my application:

$adapter = new Adapter\ArrayAdapter($this->getTempMailDomainDB());
try {
    list($local, $domain) = Utilities::parseEmailAddress($email);
} catch (\Exception) {
    return true;
}

$invalid = $adapter->isThrowawayDomain($domain);

I'd imagine this will work indefinitely, but since since utilized methods aren't documented in the readme, I'd assume that undocumented changes to them are fair game, hence the want for an official way to disable the validation.