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

Email validation with german umlauts #13215

Closed
martin-skroch opened this issue Apr 19, 2016 · 4 comments
Closed

Email validation with german umlauts #13215

martin-skroch opened this issue Apr 19, 2016 · 4 comments

Comments

@martin-skroch
Copy link

martin-skroch commented Apr 19, 2016

I have the problem that the email validation fails if I use an email with german umlauts.

I know, laravel use the filter_var function of php with the filter FILTER_VALIDATE_EMAIL, but this is outdated, because there are so-called IDNs (Internationalized domain names) which are not considered in this filter.

Now we can wait until php reworked it or we can implement an alternative respectively a small solution to convert the domain of an emal to ascii with idn_to_ascii(). The only drawback is that this function requires the intl extension for php.

Here, I have found a solution which works for me. I have implemented a Custom Validation Rules like so:

Validator::extend('idn_email', function($attribute, $value, $parameters, $validator) {
    $valueParts = explode('@', $value);
    return count($valueParts) == 2 && filter_var($valueParts[0].'@'.idn_to_ascii($valueParts[1]), FILTER_VALIDATE_EMAIL) !== false;
});

This solution only convert the domain name from idn in ascii and then we can use the filter_var again.

I think it is a clean solution. What do you say?

@themsaid
Copy link
Member

I think you might consider sending a PR with the fix.

@martin-skroch
Copy link
Author

martin-skroch commented Apr 19, 2016

That was my first thought, but I wanted to ask first whether it makes sense.

It seems to make sense, but I forgot to mention that the idn_to_ascii() function requires the intl extension for php. This must be updated in the Server Requirements.

@GrahamCampbell
Copy link
Member

Emails with international characters are invalid email addresses, and swiftmailer will not allow you to send messages to them.

@driade
Copy link
Contributor

driade commented Dec 16, 2016

Hello, good morning.

Ran on my tests with the same problem. It seems Swiftmailer is going to fix this in the next release.

swiftmailer/swiftmailer#409

Maybe it'd be "optimal" not to rely more on FILTER_VALIDATE_EMAIL and switch to "Swift_Validate::email", which seems more complete and, in the near future, will address this problem.

Not an expert on the issue but tried to send an email to "áéí@foo.com" and my email client (Mail on Mac) won't let me, though it let me "test@españa.com" through gmail with no further problems.

FILTER_VALIDATE_EMAIL fails to validate "test@españa.com".

@GrahamCampbell might be interesting reopening the issue?

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

4 participants