Improve e-mail MX validator and add tests #9489
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem with the old validator code wasn't so much that it had a bug, but the usage was a bit misleading for admins. MX records are hostnames, so if you blacklisted an IP that a MX record pointed to, but not the MX hostname itself, it would still let accounts through.
Now the validator fetches MX records, and then A records for both the original domain as well as MX records, and then checks both the hostnames and the IPs against the blacklist, so if you have blacklisted either of them, no accounts would be let through.
A future improvement may be offering the admins a choice to automatically create blacklist records for the IPs when they enter a domain name.