Mailcheck
A ruby translation of the Kicksend mailcheck javascript library which suggests a right domain when your users misspell it in an email address.
When your user types in "[email protected]", Mailcheck will suggest "[email protected]".
Mailcheck will offer up suggestions for top level domains too, and suggest ".com" when a user types in "[email protected]".
Installation
Add this line to your application's Gemfile:
gem 'mailcheck'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mailcheck
Usage
> require 'mailcheck'
> mailcheck = Mailcheck.new
> mailcheck.suggest("[email protected]")
# => {
# :address =>"user",
# :domain =>"hotmail.com",
# :full =>"[email protected]"
# }
Returns false if no suggestion:
> mailcheck.suggest("[email protected]")
# => false
Pass in a custom list of domains and TLDs:
mailcheck = Mailcheck.new(
:domains => ["gmail.com", "hotmail.com", "aol.com"],
:top_level_domains => ["com", "net", "org"]
)
Contributing
- Fork it
- 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 new Pull Request
Credits
- Mailcheck.js: the original idea
- This gist, by mmmaia - an initial port to Ruby