Using MX records to validate email addresses

后端 未结 5 2128
独厮守ぢ
独厮守ぢ 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:14

    DNS lookups can be slow at times, depending on network traffic & congestion, so that's something to be aware of.

    If I were in your shoes, I'd test it out and see how it goes. For a week or so, log all emails to a database or log file and include a field to indicate if it would be marked as spam or legitimate email. After the week is over, take a look at the results and see if it's performing as you would expect.

    Taking this logging/testing approach gives you the flexibility to test it out and not worry about loosing customer emails.

    I've gotten into the habit of adding an extra field to my forms that is hidden with CSS, if it's filled in I assume it's being submitted by a spam bot. I also make sure to use a name like "url" or "website_url" something that looks like a legitimate field name to a spam bot. Add a label for the field that says something like "Don't fill out this field" so if someone's browser doesn't render it correctly, they will know not to fill out the spam field. So far it's working very well for me.

提交回复
热议问题