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

Validators::isEmail: Add check for DNS nameservers. #269

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

janbarasek
Copy link
Contributor

  • new feature
  • BC break? no

E-mail should be valid only in case of domain name use valid MX DNS record.

Examples:

Validators::isEmail('jan@barasek.com'); // true
Validators::isEmail('jan@aaadfergrtgeaaa.com'); // true
Validators::isEmail('jan@aaadfergrtgeaaa.com', true); // false

@milo
Copy link
Member

milo commented Oct 12, 2021

You don't need MX record. A, or AAAA is sufficient to deliver e-mails.

@mabar
Copy link
Contributor

mabar commented Oct 12, 2021

Also I think checkdnsrr(idn_to_ascii($domain), 'MX')) should be used. checkdnsrr() returns bool and idn_to_ascii() is for domains like ñandu.cl (var_dump(checkdnsrr(idn_to_ascii('ñandu.cl'), 'MX'));)

Ideal would imho be to support only fully FQDN - if trailing dot is missing, add it. It should prevent multiple lookups with relative domain name. So instead of google.com, always look for google.com.

@milo
Copy link
Member

milo commented Oct 13, 2021

Part after @ can be domain (MX is required), or hostname (one of MX, A, or AAAA is required). I think checking existence of MX or A or AAAA by checkdnsrr() is sufficient.

To IDN - yes, idn_to_ascii() shoud be used, but I'm not sure, default parameters are OK.

@dg
Copy link
Member

dg commented Oct 21, 2021

@janbarasek can you update PR please?

@nechutny
Copy link

There was forum post about this 8 years ago https://forum.nette.org/en/1293-mail-adress-validation-mx-records and it contains good points which needs to be solved.

@milo
Copy link
Member

milo commented Oct 21, 2021

I don't think so

  • check MX/A - yes, it will
  • it will be slower - yes, that's the price (surely few tens of ms, not seconds)
  • process MX records - no, thats what MTA will do
  • whois database - a little bit off topic

We only want to check that domain/hostname exists, not that they has correctly configured mail delivery. If domain/hostname is wrong, MTA fails immediately (that's what we want to prevent). If domain/hostname is correct, but MX records are incorrect or host is down, MTA will use queue and will try to deliver later.

@dg dg force-pushed the master branch 8 times, most recently from 8cb1b67 to 5002ffb Compare October 26, 2021 23:33
@dg dg force-pushed the master branch 2 times, most recently from 38d3044 to a3ce3eb Compare September 27, 2023 09:53
@dg dg force-pushed the master branch 2 times, most recently from 38cc5db to 0a8a17e Compare October 17, 2023 08:26
@dg dg force-pushed the master branch 5 times, most recently from 4b7b01e to 494d200 Compare November 1, 2023 20:33
@dg dg force-pushed the master branch 5 times, most recently from b843c77 to 77e9645 Compare November 26, 2023 23:02
@dg dg force-pushed the master branch 7 times, most recently from 7ae8df7 to 0d1508c Compare December 5, 2023 14:51
@dg dg force-pushed the master branch 3 times, most recently from 5b5c893 to 81e3e6d Compare January 17, 2024 16:51
@dg dg force-pushed the master branch 2 times, most recently from b080db7 to d668e02 Compare May 3, 2024 11:20
@dg dg force-pushed the master branch 4 times, most recently from 1e73622 to d6a9961 Compare May 16, 2024 20:06
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

Successfully merging this pull request may close these issues.

None yet

5 participants