Using MX records to validate email addresses

后端 未结 5 2110
独厮守ぢ
独厮守ぢ 2020-12-01 09:41

Scenario:
I have a contact form on my web app, it gets alot of spam.
I am validating the format of email addresses loosely i.e. ^.+@.+\\..+$

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 10:20

    I see no harm doing a MX lookup with checkdnsrr() and I also don't see how false positives may appear. You don't need to escape the hostname, in fact you can use this technique and take it a little further by talking to the MTA and testing if the user exists at a given host (however this technique may and probably will get you some false positives in some hosts).

提交回复
热议问题