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

When email top level domain valid but subdomain invalid then check still passes #362

Open
ValCanBuild opened this issue Apr 20, 2023 · 7 comments
Labels

Comments

@ValCanBuild
Copy link

The DNS validation is passing for an email like the following:
[email protected]

There is a misspelling of "environsment-agency" and if you check the DNS records for environsment-agency.gov.uk they show up as empty. But the library seems to only be checking the last part of the domain - gov.uk, not the subdomain as well.

This looks wrong to me. Is it possible to fix?

@egulias
Copy link
Owner

egulias commented May 22, 2023

Hi @ValCanBuild
This is very tricky to fix. There is a thread in #301 about this.

@egulias egulias closed this as completed May 22, 2023
@ValCanBuild
Copy link
Author

ValCanBuild commented May 25, 2023

@egulias I don't quite understand how the two issues are connected. I believe this one mainly has to do with the DNSCheckValidation->checkDns function and how it only gets the last part of a host and not the whole thing.
Wouldn't it be possible to apply a fix there?

MX records should exist at the dns name equal to whatever is behind the @ in the email address. So only checking the parent domain is a bug. Source: https://www.nslookup.io/learning/dns-record-types/mx/#mx-records-below-the-zone-root

@ValCanBuild
Copy link
Author

ValCanBuild commented May 25, 2023

@egulias I believe the issue might have been caused by this change: #355

There's a valid test case for this inside DNSCheckValidationTest but it's marked as skipped for some reason:
https://github.com/egulias/EmailValidator/blob/97c28cd611278a5686b7f8b47f4136472bebbe1f/tests/EmailValidator/Validation/DNSCheckValidationTest.php#LL97C33-L97C33

    public function testDNSWarnings()
    {
        $this->markTestSkipped('Need to found a domain with AAAA records and no MX that fails later in the validations');
        $validation = new DNSCheckValidation();
        $expectedWarnings = [NoDNSMXRecord::CODE => new NoDNSMXRecord()];
        $validation->isValid("[email protected]", new EmailLexer());
        $this->assertEquals($expectedWarnings, $validation->getWarnings());
    }

@ValCanBuild
Copy link
Author

@egulias just pinging again on this as I believe it's an open bug in 4.0.1 and above versions of the library.

@egulias egulias reopened this Jun 14, 2023
@egulias egulias added the bug label Jun 14, 2023
@egulias
Copy link
Owner

egulias commented Jun 14, 2023

Hi @ValCanBuild
The reason is written in the skipping function
Need to found a domain with AAAA records and no MX that fails later in the validations
The thing is I haven't been able to actually test the code that does that type of validation because it looks like it either pass or fails at other points.
And also need a domain with AAAA and no MX.
I'm happy to review a PR with a proposed fix.

@ValCanBuild
Copy link
Author

@egulias here's a domain with AAAA records or no MX records you can use for the test: dnslookup.io
Proof: https://www.nslookup.io/domains/dnslookup.io/dns-records/

@ValCanBuild
Copy link
Author

@egulias I don't believe this is an issue anymore thanks to #376

Happy to close if you are?

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

No branches or pull requests

2 participants