Gem validatemail
, by hix.dev
The validatemail
gem is used to make sure that provided email addresses are
valid. Providing all ENV variables, you can validate 1.4k email addresses
monthly, for free.
- Abstract: 100 / month
- API Layer: 100 / month
- Hunter: 50 / month
- Reacher: 50 / month
- WhoisXML: 1000 / month
- Zerobounce: 100 / month
Every time it runs, it hits the randomly selected API and returns the normalized data. If the HTTP response code is other than 200, it hits the next one, and so on.
Usage
- Update to the latest Ruby 3.2.1, using any of the Ruby version managers.
- Do one of the following:
- Run
gem install validatemail
- Run
bundle add validatemail
- In your runtime, add following
ENV
variables:
-
VALIDATEMAIL_ABSTRACT_API_KEY
- see the documentation -
VALIDATEMAIL_APILAYER_API_KEY
- see the documentation -
VALIDATEMAIL_HUNTER_API_KEY
- see the documentation -
VALIDATEMAIL_REACHER_API_KEY
- see the documentation -
VALIDATEMAIL_ZEROBOUNCE_API_KEY
- see the documentation -
VALIDATEMAIL_WHOISXML_API_KEY
- see the documentation
- Use the following code
$ validatemail = Validatemail::API.new("valid@example.com")
$ validatemail.ok?
> true | false
$ validatemail.data
> Validatemail::Struct(
email: string
valid: boolean
validated_by: enum("Abstract" | "Apilayer" | "Hunter" | "Reacher" | "Whoisxml" | "Zerobounce")
autocorrect: string | null
score: float | null
first_name: string | null
last_name: string | null
free: boolean | null
)
Development
Clone the repository and run bundle install
. An example script to play around
with the development gem version would be:
Gemfile
source "https://rubygems.org"
gem "validatemail", path: "/path/to/email-validator-rubygem"
validatemail.rb
require "bundler/setup"
require "validatemail"
ENV['VALIDATEMAIL_ABSTRACT_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_APILAYER_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_HUNTER_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_REACHER_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_ZEROBOUNCE_API_KEY'] = "YOUR_KEY"
ENV['VALIDATEMAIL_WHOISXML_API_KEY'] = "YOUR_KEY"
validatemail = Validatemail::API.new("valid@example.com")
binding.pry
with those 2 files in place, you can
bundle install
ruby validatemail.rb
Tests
Run bundle exec rspec
.
Code Quality
- Run
bundle exec rubocop -a
. - Run
bundle exec fasterer
.