How to validate email addresses in Ruby

Our free API to validate e-mail addresses is really easy to use in Ruby.


Validate e-mail in Ruby with net::http object

require 'uri'
require 'net/http'
require 'openssl'

url = URI("")

http =, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request =
request["x-rapidapi-host"] = ''
request["x-rapidapi-key"] = 'YOUR-API-KEY'

response = http.request(request)
puts response.read_body

This will return a JSON-array with information about the domain, and if you should block it or not.


Validate e-mail in Ruby with Unirest object

response = Unirest.get "",
    "X-RapidAPI-Host" => "",
    "X-RapidAPI-Key" => "YOUR-API-KEY"


You can of course just send it as a regular GET-request to that URL also, in your favorite way, as long as you have the API-key in the header.

You will receive a JSON response, telling you if this is a disposable e-mail to block, or if there are other issues with the domain:


   "valid": true,
   "block": true,
   "disposable": true,
   "domain": "",
   "text": "Disposable e-mail",
   "reason": "Heuristics (2a)",
   "risk": 91,
   "mx_host": "",
   "mx_info": "Using MX pointer from DNS with priority: 10",
   "mx_ip": "",
   "last_changed_at": "2020-06-11T09:56:02+02:00"

This will tell you if you should block the domain or not, and the reason to why the API thinks so (disposable e-mail, etc). You can also see more detailed documentation of the response here.

To get started for free, and get an API key, click here!