Email::Valid
Email::Valid is a simple class to check the validity of email addresses, copied from the perl Email::Valid module.
Quick Start
if Email::Valid.address(email_address)
# do something
end
Usage
Call the class method:
if Email::Valid.address(email_address)
# do something
end
or the instance methods:
email = Email::Valid.new(:check_domain => true, :check_rfc822 => true)
if email.valid(email_address)
# do something
else
raise "Invalid Email: #{email.errors.join ', '}"
end
Possible arguments to Email::Valid.new
:check_domain - checks the mx record for the domain, default true
:check_rfc822 - checks the address against the rfc822 pattern, default true
Other instance methods:
valid_domain(email) - returns true if it finds a valid mx record, false otherwise
valid_rfc822(email) - returns true if it matches the rfc822 pattern, false otherwise
Credit
This is an incomplete adaptation of the perl Email::Valid module.