Sign Up Free

Ruby Email Verification SDK — Verify Emails in Ruby

Everything you need to integrate email verification into your application.

Getting Started

The official Ruby SDK provides an idiomatic interface for email verification. Supports Ruby 2.7+ including 3.x, uses Faraday for HTTP, and includes Rails integration.

Install via gem and verify with clean Ruby syntax. Includes a Rails engine with custom validator and ActiveJob support. For no-code verification, visit our email verifier.

Code Example

gem install ev_email_verifier

require 'ev_email_verifier'

client = EvEmailVerifier::Client.new(api_key: 'YOUR_API_KEY')
result = client.verify('user@example.com')

puts result.status      # "deliverable"
puts result.score       # 95
puts result.disposable? # false

# Rails model validation
class User < ApplicationRecord
  validates :email, email_verification: true
end

Authentication & Setup

Install: gem install ev_email_verifier. For Rails, add to Gemfile and run bundle install. Run rails generate ev_email_verifier:install for configuration initializer.

Getting Started

Install the Ruby email verification SDK by running gem install ev_email_verifier or adding gem 'ev_email_verifier' to your Gemfile and running bundle install. The gem supports Ruby 2.7 and above, including Ruby 3.0, 3.1, 3.2, and 3.3. It uses the Faraday HTTP client for flexible adapter support and follows standard Ruby gem conventions. For Rails applications, the gem includes an engine that auto-configures itself when the gem is loaded via Bundler.

After installation, create a client instance by passing your API key. For Rails applications, run rails generate ev_email_verifier:install to generate an initializer at config/initializers/ev_email_verifier.rb where you can configure the API key, timeout, retry settings, and sandbox mode. The initializer reads ENV['EV_API_KEY'] by default. The gem also provides a custom ActiveModel validator that you can use directly in your models, an ActiveJob integration for background verification, and Rack middleware for verifying emails on incoming form submissions.

Code Examples

Single Email Verification

require 'ev_email_verifier'

client = EvEmailVerifier::Client.new(api_key: ENV['EV_API_KEY'])

result = client.verify('user@example.com')

puts result.email          # "user@example.com"
puts result.status         # "deliverable"
puts result.score          # 95
puts result.disposable?    # false
puts result.role_account?  # false
puts result.mx_found?      # true
puts result.smtp_provider  # "google"

Batch Email Verification

require 'ev_email_verifier'

client = EvEmailVerifier::Client.new(api_key: 'YOUR_API_KEY')

# Submit batch job
emails = ['alice@example.com', 'bob@company.org', 'test@temp-mail.io']
job = client.verify_batch(emails)
puts "Job ID: #{job.id}, Status: #{job.status}"

# Wait for completion with built-in polling
results = client.wait_for_batch(job.id, poll_interval: 5, timeout: 600)

# Process results
results.each do |result|
  puts "#{result.email}: #{result.status} (score: #{result.score})"
end

# Filter deliverable emails
valid = results.select { |r| r.status == 'deliverable' }
puts "Valid: #{valid.count}, Total: #{results.count}"

Rails Model Validation

# app/models/user.rb
class User < ApplicationRecord
  validates :email, presence: true, email_verification: true
end

# app/models/subscriber.rb
class Subscriber < ApplicationRecord
  validates :email, email_verification: {
    reject_disposable: true,
    reject_role_based: true,
    min_score: 80
  }
end

# app/jobs/verify_email_job.rb
class VerifyEmailJob < ApplicationJob
  queue_as :default

  def perform(user_id)
    user = User.find(user_id)
    client = EvEmailVerifier::Client.new
    result = client.verify(user.email)
    user.update(email_verified: result.status == 'deliverable')
  end
end

Error Handling

The Ruby SDK raises specific exception classes within the EvEmailVerifier namespace. AuthenticationError is raised for invalid or expired API keys. RateLimitError is raised when you exceed your request quota and provides a retry_after attribute indicating the wait time in seconds. ValidationError is raised for malformed email addresses. NetworkError covers connection timeouts, DNS failures, and other transport-level issues. All exceptions inherit from EvEmailVerifier::Error.

The SDK includes automatic retry logic with exponential backoff for transient errors, including 429 rate limit responses and 5xx server errors. You can configure max_retries and retry_delay in the client constructor or the Rails initializer. For batch operations, individual failures are captured in each result's error attribute without halting the batch. The client exposes a rate_limit_remaining method that returns the number of requests remaining in the current window, enabling you to implement proactive throttling in high-volume applications.

require 'ev_email_verifier'

client = EvEmailVerifier::Client.new(
  api_key: 'YOUR_API_KEY',
  max_retries: 3,
  retry_delay: 1
)

begin
  result = client.verify('user@example.com')
  puts "Status: #{result.status}"
rescue EvEmailVerifier::RateLimitError => e
  puts "Rate limited. Retry after #{e.retry_after} seconds."
rescue EvEmailVerifier::AuthenticationError
  puts "Invalid API key. Check your EV_API_KEY."
rescue EvEmailVerifier::ValidationError => e
  puts "Invalid input: #{e.message}"
rescue EvEmailVerifier::Error => e
  puts "Verification failed: #{e.message} (code: #{e.code})"
end

Frequently Asked Questions

The SDK supports Ruby 2.7 and above, including Ruby 3.x. Install with gem install ev_email_verifier or add to your Gemfile. The SDK uses Faraday for HTTP requests and follows Ruby conventions for method naming and error handling.

Yes, the SDK includes a Rails engine with a custom validator. Add validates :email, email_verification: true to your model. The engine provides a configuration initializer, background job support via ActiveJob, and a generator for setup.

Yes, the SDK works with Sidekiq, Resque, DelayedJob, and ActiveJob. Batch verification methods return job IDs that can be polled or monitored via webhooks. The SDK includes helper methods for Sidekiq worker integration.

Start Verifying Emails Today

100 daily free verifications. No credit card required. Full API access on all plans. Visit our email verifier to get started.

Try our free email verifier — verify any email instantly, no signup required. Need bulk verification? Upload your list and clean thousands of emails in minutes.

Developers: integrate email verification into your app with our RESTful API — SDKs for 7 languages.

Free tools: SPF checker · DKIM checker · SMTP tester