Yeah, we basically developed this system on our live mail server to see what it did, and ended up with a hybrid approach.
We do about 3 checks with this "anti-spoofing" check, since just MX is not fine enough.
1. We do an MX lookup. If there is no MX record, we verify a few things about the IP / name itself. If no A record, it is an invalid domain.
Any DNS failure is deemed inconclusive.
So, once we have the MX records, we check that none of them resolve to bogus IP addresses (like localhost, or any local IP of the WinGate machine), and that the names aren't obviously bogus such as "dev.null" or "localhost". these are deemed poisoned MX records, and are treated harshly.
Next step. We check to see if the IP of the client is in the same class C subnet as any MX resolved IP. If so, then good.
Else, we do a PTR lookup, followed by an A record lookup. If there is no PTR record, we fail at this point. This is the usual cause for manual whitelist entries.
If the A record lookup on the result of the PTR lookup doesn't match we also fail.
If they match (usual case surprisingly), then we do a lexical comparison of the validated name associated with the IP (result of the PTR) with
a) the domain being delivered for
b) the names of all the MX servers for the domain.
to one significant token in the name. Significant being things other than .com, .edu, country codes, etc etc.
b) catches the case where an ISP receives mail (is MX) for a domain, yet the client of the ISP delivers directly.
this combination we found had the smallest number of false rejections, but we still had to add manual entries where:
1. The IP of the client had no reverse DNS.
2. The client had no MX for their mail
This is why we offered 2 modes of operation in the end (initial betas of this were all "check all except...") . So now on our own server, we add commonly spoofed domains to the list of things to check, rather than adding commonly blocked domains to the list of things not to check.
However, the former more brutal method certainly we found to be very effective. I guess if we had been less lazy about false positives, we could be running it that way. It is a bit tough when you need to take sales email from all over.
One improvement that has been suggested is to allow the deferral of the check until after the RCPT command, and allow certain recipient email addresses to be whitelisted. This would allow all mail into
sales@wingate.com for example, but be more conservative for other addresses. This is planned for upcoming.
Adrien