Skip to content

Sign2Pay/email_validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email Validation

Codeship Status for Sign2Pay/email_validation

This straightforward Ruby class will connect to Mailgun's Email Validation Service and tell you if the provided email is valid or not.

Configuration

Configure your Mailgun public key:

EmailValidation.configure do |config|
  config.mailgun_public_key = 'pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7'
end

Use instructions

EmailValidation::Validate.new("[email protected]").valid? # => false

or do it in two steps if that's more your style:

validation = EmailValidation::Validate.new("[email protected]")
validation.valid? # => false

Background Job

I suggest you create a background job to check email validity. You don't really want to depend on Mailgun being online in order to register a new user. A possible solution using a boolean field on User is this:

require 'email_validation/validate'

class EmailValidationJob < ApplicationJob
  queue_as :default

  def perform(user)
    user.update email_valid: email_valid(user.email)
  end

  private

  def email_valid(email)
    EmailValidation::Validate.new(email).valid?
  end
end

You can then ask the user to change their email.

Installation

Add this line to your application's Gemfile:

gem 'email_validation', github: 'sign2pay/email_validation'

Currently this gem hasn't been released to Rubygems. We would need a new name I think. If anyone is interested in me doing that, open an issue.

To install this gem:

$ bundle

Development

rake test

Contributing

Open an issue or submit a pull request. We'll work it out!

Copyright

Copyright Sign2Pay NV. Licensed using the MIT license.

About

Ruby class to poll Mailgun's email validator service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published