Email Checker
Check if an email address can receive E-mails.
Installation
Add this line to your application's Gemfile:
gem 'email_checker'
And then execute:
$ bundle
Or install it yourself as:
$ gem install email_checker
How do this gem works
For an email address to receive e-mails, it has to meet the following:
- The domain must have MX records.
- The MX records must point to a valid server and
- That server must have the corresponding A records.
Now, that does not ensure that the email actually exists in the server, for that, we have to pretend to send an e-mail and check if the seerver is OK with it (respond with status 250). If you want to read more about it you can read the RFC 821.
For this gem to pretend to send an email you have to provide a valid email address from whitch the email "will be sent". If you don't, the server might reject the message without checking if the email exists. In this gem that is the verifier_email
.
It is noteworthy that this method can result in your server being blacklisted since its known as a spamming technique.
Usage
You can provide the verifier_email
by passign it to the check
method in the second parameter:
EmailChecker.check(email, verifier_email=nil)
Or in an initializer:
EmailChecker.config do |config|
config.verifier_email = 'realname@realdomain.com'
end
EmailChecker.check(email)
Contributors
email_checker
it's inspired on Kamilc email_verifier gem. The diference is that email_checker
validates the domain MX records and its server before it pretends to send an email, this way it is less posible that your server get blacklisted.
Contributing
- Fork it ( https://github.com/[my-github-username]/email_checker/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request