Yii2: Email validator error on valid email.

Created on 9 Jul 2015  Â·  5Comments  Â·  Source: yiisoft/yii2

Hey guys.
I've been testing our app against possible email submissions (and some case insensitive checks but that's beyond the scope of this issue) and I noticed that some valid emails were being rejected by the email validator. The email set I used for testing come from the examples here: https://en.wikipedia.org/wiki/Email_address

Here are the emails that fail:

"much.more unusual"@example.com
admin@mailserver1
"[email protected]"@example.com
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
"()<>[]:,;@\\\"!#$%&\'*+-/=?^_`{}| ~.a"@example.org
" "@example.org
üñîçøðé@example.com
üñîçøðé@üñîçøðé.com
bug

Most helpful comment

It's a popular thing to discuss :)

The point of the validator is to verify if the string meets the generic requirements to an abstract email address defined by RFC

The problem is that the most public email services does not allow to create fully RFC-compatible email address.

In case you validate email addresses according to RFC and have working website with at least 10k users, could you share statistics on how many users use emails that are rejected by EmailValidator?

All 5 comments

admin@mailserver1
"[email protected]"@example.com

these are okay to reject because the first is a local address, you do not want your webserver try to resolve an internal name and try to deliver mails there.
second is delivering via a different server @ in the mailbox part is hardly allowed by any MTA.
allowing these is a security issue.

about the "..." syntax, while they may be valid, a normal user would not even understand what "" means in his email address so I am quite sure there is no mail provider that allows email addresses like that.

üñîçøðé@example.com
üñîçøðé@üñîçøðé.com

these are the only two I would consider to be important. They should work.

these are okay to reject because...

@cebe I'm sorry, I can not agree with that. The point of the validator is to verify if the string meets the generic requirements to an abstract email address defined by RFC. It has nothing to do with host resolution, mail delivery or MTAs. What if we wand to develop an intranet web application and we want to validate local mailboxes? What is we use our custom MTA?

to develop an intranet web application and we want to validate local mailboxes

this would show a usecase for adding an extra flag to EmailValidator in which local emails will also be accepted

It's a popular thing to discuss :)

The point of the validator is to verify if the string meets the generic requirements to an abstract email address defined by RFC

The problem is that the most public email services does not allow to create fully RFC-compatible email address.

In case you validate email addresses according to RFC and have working website with at least 10k users, could you share statistics on how many users use emails that are rejected by EmailValidator?

I've added tests to confirm that üñîçøðé addresses work fine.
Right not I can't see any problems with local email addresses, especially when checkDNS property is set to false. In case I am wrong - please, open a separate issue with detailed description.
Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newscloud picture newscloud  Â·  3Comments

SamMousa picture SamMousa  Â·  3Comments

indicalabs picture indicalabs  Â·  3Comments

AstRonin picture AstRonin  Â·  3Comments

chaintng picture chaintng  Â·  3Comments