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?
I think you might consider sending a PR with the fix.
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.
Emails with international characters are invalid email addresses, and swiftmailer will not allow you to send messages to them.
Hello, good morning.
Ran on my tests with the same problem. It seems Swiftmailer is going to fix this in the next release.
https://github.com/swiftmailer/swiftmailer/pull/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?
Most helpful comment
Hello, good morning.
Ran on my tests with the same problem. It seems Swiftmailer is going to fix this in the next release.
https://github.com/swiftmailer/swiftmailer/pull/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?