Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'mailgun'
- require 'pp'
- api_key = ARGV[0]
- raise "no api key" if api_key.nil?
- data = DATA.read
- emails = data.split("\n")
- puts "Emails size: #{emails.size}"
- puts "Emails uniq size: #{emails.uniq.size}\n"
- emails.uniq.each_with_index do |email, index|
- mg_obj = Mailgun::Address.new(api_key)
- res = mg_obj.validate(email)
- unless res["is_valid"]
- puts "\nInvalid email address #{email}:"
- pp res
- else
- print "."
- end
- # # Example response:
- # {
- # "address" => "alice@mailgun.net",
- # "did_you_mean" => nil,
- # "is_valid" => true,
- # "parts" => {
- # "display_name" => nil,
- # "domain" => "mailgun.net",
- # "local_part" => "alice",
- # },
- # }
- end
- puts "\nDone"
- __END__
- new line separated list of emails goes here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement