Reject junk email addresses with email veracity

Nov 20, 2007

Carsten Nielsen has created an amazing plugin for rails called email veracity. It takes all of the heavy lifting out of what can often be a problematic part of data validation, and takes it a step further than most.

Not only does email veracity remove the need for a convoluted regexp to match against the email string, but it will also check the domain records to ensure that the MX entry is currently accepting mail, wow!

So how do I check the format of an email address?

Add this to the code on your model definition:

validates_email_veracity_of :email


that single line does the domain check too! You can turn it off, apply a timeout, and/or a custom error message if you like too:

validates_email_veracity_of :email, :domain_check => false, :timeout => 5, :message => "is not valid"


Installation

It's available as a plugin so use piston, or the following command:

script/plugin install http://svn.savvica.com/public/plugins/validates_email_veracity_of


Hi, I'm Glenn! 👋 I've spent most of my career working with or at startups. I'm currently the Director of Product @ Ockam where I'm helping developers build applications and systems that are secure-by-design. It's time we started securely connecting apps, not networks.

Previously I led the Terraform product team @ HashiCorp, where we launched Terraform Cloud and set the stage for a successful IPO. Prior to that I was part of the Startup Team @ AWS, and earlier still an early employee @ Heroku. I've also invested in a couple of dozen early stage startups.