Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rich_email_validator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rich_email_validator

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Rich Email Validator

Gem Version Build Status Coverage Status Dependency Status Code Climate

A set of helpers to validate emails:

  • Validate an email
  • Filter a list of emails
  • Filter a list of emails from file
  • Filter a list of emails from file and output to file

It works as follows:

  • Checks the availability of the mx records of the email's domain. This is done via a DNS lookup.
  • Checks the format of the email via a regular expression that can be configured. This is done for performance only.
  • Use a configurable number of threads to check thousands of emails in minutes.

Installation

Add this line to your application's Gemfile:

gem 'rich_email_validator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rich_email_validator

Usage

Validate an email

require 'rich_email_validator'
RichEmailValidator.valid_email?('khellls@gmail.com') # => true
RichEmailValidator.valid_email?('khellls@g.com') # => false because of DNS lookup check

Set a predfined Regexp

It's only used for performace reasons to filter the format of an email before doing a DNS lookup check.

The current value is:

/\A[\w!#$%&'*+\/=?`{|}~^-]+(?:\.[\w!#$%&'*+\/=?`{|}~^-]+)*@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\Z/i

You can change it:

# Customized email regular expression
RichEmailValidator.email_regexp = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i 

Filter a list of emails

list = ['khellls@g.com', 'khellls@gmail.com']
RichEmailValidator.filter_list(list) #=> ["khellls@gmail.com"]

# You have a fine grained control, so you can control threads count
# Default is 20, max 100
RichEmailValidator.filter_list(list, threads_count: 15)

Filter a list of emails from file

file_path = '/path/to/emails_list'
File.readlines(file_path).size #=> 15 
RichEmailValidator.filter_file(file_path).size #=> 10 

# You have a fine grained control, so you can control threads count
# Default is 20, max 100
RichEmailValidator.filter_file(file_path, threads_count: 15)

Filter a list of emails from file and output to file

file_path = '/path/to/emails_list'
output_path = '/path/to/output'
File.readlines(file_path).size # => 15 
RichEmailValidator.export_valid_list(file_path, output_path)
File.readlines('output.txt').size #=> 10 

# You have a fine grained control, so you can control threads count
# Default is 20, max 100
RichEmailValidator.export_valid_list(file_path, output_path, threads_count: 15)

Contributing

  1. Fork it ( https://github.com/[my-github-username]/rich_email_validator/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

FAQs

Package last updated on 16 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc