Integrations
Rails integration
One line in a Rails model fails an email address that cannot receive mail, with an ActiveModel validator built on our Ruby client library. Each address is checked once, and a real person can still sign up when the API cannot answer in time.
- Status: Setup guide
- One line in your model
# Gemfile
gem "email-validation-rails", path: "vendor/email-validation-rails"
# app/models/user.rb
class User < ApplicationRecord
validates :email, presence: true, deliverable_email: true
endAt a glance.
- Status
- Setup guide. Not listed on a marketplace yet: you set it up yourself in a few steps, below and in the full guide.
- For
- Rails developers who want sign-up, checkout and contact forms to refuse addresses that will bounce, and anyone with an ActiveModel class, with or without Rails.
- You need
- ActiveModel 7.1 or newer, Ruby 3.2 or newer, and an API key made for it, with a daily credit cap, with the permission Validate addresses.
- Costs
- 1 credit = 1 validated address, as with any API request. Free: unknown results, API errors, malformed addresses and test addresses on sandbox.email-validation.org.
- Full guide
- Read the full setup guide
Typical uses.
Clean sign-ups
Add the validator to the email field of your User model, so an address that cannot receive mail gets an error on the form instead of an account.
Stricter fields
Fail disposable addresses on a work email field, or refuse the form when the check cannot finish, with options on that one validation.
Your own messages
Translate or override the English messages in your locale files, or pass message: to one validation. The messages never show the API’s own error text.
Set it up. 4 steps.
The short version of the full setup guide, which stays the reference when a step does not match what you see.
Download the gem
The gem is not on RubyGems yet. Download it from the guide and unzip it into your app’s vendor/ folder, so that you have vendor/email-validation-rails/.
Add it to your Gemfile
Add
gem "email-validation-rails", path: "vendor/email-validation-rails"and runbundle install.Set your key
Create a key with Validate addresses and a daily credit cap, and set it in your environment as
EV_API_KEY, or read it from your credentials in the initializer. Never put it in code.Validate the field
Add
deliverable_email: trueto the field’s validation, then tryaccepted@sandbox.email-validation.org(passes) andno_mailbox@sandbox.email-validation.org(fails) at no cost.
Good to know.
- Only invalid fails by default. Set block_disposable to true to fail disposable addresses as well; catch_all and unknown pass unless you add them to fail_on.
- When the check cannot finish (a timeout, no connection, a 5xx or 429 answer, no credits or no key), the address passes and a warning goes to Rails.logger with the error code and request id, never the address. With fail_open set to false, the field gets an error instead.
- Each result is kept in Rails.cache for an hour under a hash of the address, so a form sent again after fixing another field is not checked or charged again. Only the status is kept, and unknown results are not kept.
- A malformed address is refused without a request, and nothing is retried: a slow mail server answers unknown, which passes and is free.
- For EU data residency, set the base URL in the initializer to
https://api-eu.email-validation.org: the same key works on both.
Updated · Maintained by the email-validation.org team