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

DNS validation succeeds for missing mx records #258

Closed
tpetry opened this issue Sep 2, 2020 · 3 comments
Closed

DNS validation succeeds for missing mx records #258

tpetry opened this issue Sep 2, 2020 · 3 comments

Comments

@tpetry
Copy link

tpetry commented Sep 2, 2020

The email address xxx@icluod.com (transposed o and u) passes dns validations, but in my opinion it should not. The dns validation recognizes that the icluod.com domain has an A record but no MX record. The validation is successful and a warning is stored that no mx record could be found.

But is this really the correct semantics that the dns validator should do? For this domain, it will return that everything is valid and you can send an email to the recipient. However, if you check the warnings (which not everyone will do), you will see that it is indeed invalid, since there is no mx record for the domain.

One could argue that the caller has to add the logic for checking the warning. The laravel framework (#34092) believes that the return code is the only relevant result for detecting whether an email address is correct and warnings should not lead to a validation error. That is, it would only fail if this library changes its behavior.

So what is the reason for the current (strange?) behavior.

@egulias
Copy link
Owner

egulias commented Sep 6, 2020

Hi @tpetry , it is a valid point the one you are rising. The DNS validation was inherited in "logic" from Dominic Sayer's "isemail" function/lib.
In that, the non-existance of an MX records has this same behaviour.

The point is that changing a behaviour would force a major version change. I'm working on a new version and it could fit.

Meanwhile I can suggest you add the logic by wrapping the validator in a new validator implementing the interface. I think very recently this ability was merged into laravel.

@ThibaudDauce
Copy link

ThibaudDauce commented Nov 25, 2020

Hi,

The RFC says that if a MX is not present, the domain is still valid with a A or a AAAA record. The new implementation could refuse valid email addresses.

https://en.wikipedia.org/wiki/MX_record

In the absence of an MX record, email senders will attempt delivery to the address record - e.g. example.com.

This is based on RFC 5321 sec. 5, which states :

SMTP clients must look up an MX record;
If (and only if) no MX record for the domain is present, treat the domain as if it had an MX record with the given domain as the target hostname and a preference value of 0
Perform A or AAAA lookups as required to determine the IP address of the target hostname

@egulias
Copy link
Owner

egulias commented Dec 29, 2020

Behaviour change has been done for v3 to be a little bit more "real life" friendly.

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

No branches or pull requests

3 participants