Skip to content

Instantly share code, notes, and snippets.

@erwanjegouzo
Created July 27, 2013 20:35
Show Gist options
  • Save erwanjegouzo/6096200 to your computer and use it in GitHub Desktop.
Save erwanjegouzo/6096200 to your computer and use it in GitHub Desktop.
jetable.org is a great service to generate a temporary email which you can use to signup and avoid spam. Run this script from your CLI to have an email generated for you, using jetable.org service.
require 'rubygems'
require 'mechanize'
require 'resolv'
# check if first argument exists
if ARGV.length == 0
abort "ERROR: First argument must be your email\n"
end
EMAIL = ARGV[0]
URL = "http://www.jetable.org/en/index"
def validate_email_domain(email)
domain = email.match(/\@(.+)/)[1]
Resolv::DNS.open do |dns|
@mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
end
@mx.size > 0 ? true : false
end
# check if email is valid
if validate_email_domain(ARGV[0]) == false
arbort "ERROR: Email not valid"
end
agent = Mechanize.new { | agent |
agent.user_agent_alias = 'Mac Safari'
}
# Get the start page
start_page = agent.get(URL)
start_form = start_page.forms.first
start_form.email = EMAIL
available_times = start_form.field_with(:name => 'time').options
start_form.time = available_times.first
confirm_page = start_form.submit
puts "All done, check you email for confirmation"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment