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'm currently Director of Product @ HashiCorp, and we're hiring! If you'd like to come and work with me and help make Terraform Cloud even more amazing we have multiple positions opening in Product ManagementDesign, and Engineering & Engineering Management across a range of levels (i.e., junior through to senior). Please send in an application ASAP so we can get in touch.