0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
Library to fix invalid emails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 0.8.23
~> 13.0.6
~> 3.12.0
~> 1.50.2
 Project Readme

Email Repair

Gem Version Build Status Coverage Status

Email Repair is a utility for sanitizing and validating user-provided email address.

Installation

Add this line to your application's Gemfile:

gem 'email_repair'

And then execute:

$ bundle

Or install it yourself as:

$ gem install email_repair

Usage

require 'email_repair'
require 'ostruct'

EmailRepair::Mechanic.new.repair('blah@gmail')
# "blah@gmail.com"

EmailRepair::Mechanic.new.repair_all(%w[One@@two.com bleep@blop plooooooop])
# <OpenStruct sanitized_emails=["one@two.com"], invalid_emails=["bleep@blop", "plooooooop"]>

Public Methods

EmailRepair::Mechanic#repair(email)

Takes a single email address, applies the available repairs to it and returns the repaired email. If the email cannot be repaired, nil is returned instead.

EmailRepair::Mechanic#repair_all(emails)

Takes an array of emails, applies available repairs to each email and returns an OpenStruct containing keys sanitized_emails: with a unique array of the emails that were able to be repaired, and invalid_emails: with unique array of the emails that were unable to be repaired

EmailRepair::Constants::email_regex

Returns a regular expression to be used to validate user-supplied email addresses.

Available Repairs

CommonMistakeRepair

Repairs common email typos:

  • downcases the email
  • removes white space
  • removes duplicate @ symbols
  • replaces .c0m with .com
  • replaces commas with periods

CommonDomainSuffixRepair

Adds missing top-level domain for common email domains. For example, it replaces blah@gmail with blah@gmail.com.

CommonDomainPeriodAdder

Adds missing period between the domain and top-level domain for common email domains. For example, it replaces blah@gmailcom with blah@gmail.com.

CommonDomainAtAdder

Replaces '#', '.', or '-', with '@', or adds missing @ symbol for common domains. For example, it replaces blahgmail.com and blah#gmail.com with blah@gmail.com.

CommonDomainSwapRepair

Fixes swapped letters ('ia' instead of 'ai') in common domains. For example, it replaces blah@gmial.com with blah@gmail.com.

EmailRegexRepair

Extracts the email address from strings that contain other text. For example, it replaces blah <blah@email.com> with blah@email.com.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/email_repair/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