Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot be used with International email addresses #92

Open
BelleNottelling opened this issue Nov 9, 2023 · 0 comments
Open

Cannot be used with International email addresses #92

BelleNottelling opened this issue Nov 9, 2023 · 0 comments

Comments

@BelleNottelling
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant