Tutorial: How to Use an Email Verification API with Ruby

Using an API for email verification involves sending a GET request to the API endpoint. Here's how you can do this using Ruby:

                        
require 'net/http'
require 'uri'
require 'json'

email = 'Email_Address'  // Replace with the email you want to verify
token = 'YOUR_API_KEY'  // Replace with your actual API key

uri = URI("https://api.ValidEmail.net/?email=#{email}&token=#{token}")

response = Net::HTTP.get_response(uri)

if response.is_a?(Net::HTTPSuccess)
    data = JSON.parse(response.body)

    puts "Email is valid: #{data['IsValid']}"
    puts "Score: #{data['Score']}"
    puts "Email state: #{data['State']}"
    puts "Reason: #{data['Reason']}"

    data['EmailAdditionalInfo'].each do |info|
        puts "#{info['Key']}: #{info['Value']}"
    end
else
    puts "HTTP request failed: #{response.code} #{response.message}"
end
                    

Remember to replace 'Email_Address' and 'YOUR_API_KEY' with the actual email address you want to verify and your actual API key.