• Stars
    star
    129
  • Rank 279,262 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 16 years ago
  • Updated almost 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Email Veracity is deprecated and has not been actively maintained for over 6 years.

DEPRECATION NOTICE

Email Veracity was my very first open source project. Six years ago, it seemed like a cool idea, but it's now pretty common knowledge that trying to validate email addresses beyond a loose format check will likely yield false-positives. The whole idea of including a library for that seems silly.


Email Veracity 101

Let's explore the different functionality that Email Veracity provides and some simple ways you can integrate this functionality into your code without needing to rely on a flaky guy like me!

Validating an address for format

Trying to explicitly validate an email address for total RFC compliance is extravagantly complex, so why bother? Send a verification email to ensure that the user has provided a functioning address. If you still think that having a more robust check is necessary, the regex used in Email Veracity is from here and is a pretty good compromise between obscene complexity and useful robustness.

email = '[email protected]'

if email =~ /\A[^@]+@[^@]+\Z/
  puts 'probably valid'
  send_verification_to(email)
else
  puts 'definately not valid'
end

Extracting the domain portion of an email address

There are libraries out there for formally parsing email addresses and you can use those to get the domain portion of the email address, but we can also just use a little regular expression.

email = '[email protected]'
match = /@([\w\.\-]+)\Z/i =~ email

if match
  puts 'domain is: ' + match[1]
else
  puts 'no domain found'
end

Looking up records on the domain

I highly discourage using this method to actually validate email addresses in-line with a request; it will absolutely yield false-positives.

require 'resolv'

A  = Resolv::DNS::Resource::IN::A  # Address records
MX = Resolv::DNS::Resource::IN::MX # Mail-exchange records
NS = Resolv::DNS::Resource::IN::NS # Name server records

def lookup(host, type)
  Resolv::DNS.new.getresources(host, type)
end

a_records  = lookup('gmail.com', A)
mx_records = lookup('gmail.com', MX)
ns_records = lookup('gmail.com', NS)

puts a_records.map { |r| r.address.to_s }
puts mx_records.map { |r| r.exchange.to_s }
puts ns_records.map { |r| r.name.to_s }

Check out the Ruby Standard Library Documentation for more ways to use Resolv::DNS in your project.

More Repositories

1

lcbo-api

A crawler and API server for Liquor Control Board of Ontario retail data
JavaScript
188
star
2

lcbo

A no longer functioning library for parsing and crawling LCBO.com
Ruby
39
star
3

ember-fsm

[Maintenance Mode] A promise-aware finite state machine implementation for Ember
JavaScript
39
star
4

haversine-objc

Haversine in Objective-C: Calculate the distance between two points.
Objective-C
25
star
5

boffin

Hit tracking library for Ruby using Redis
Ruby
14
star
6

ember-drag-drop-example

An example of a way that you can use HTML5 drag and drop in your Ember app.
JavaScript
11
star
7

gcoder

Geocodes stuff using Google Geocoding API (V3) and caches the results somewhere, if you want.
Ruby
10
star
8

labici-magento-shopify-migrator

Tooling to migrate the La Bicicletta online store from Magento 1.9 to Shopify
Ruby
5
star
9

propro

No longer maintained, check out heycarsten/propro-ansible instead
Shell
5
star
10

utility-server

[Work in Progress] A Docker image to be used as a personal jump/utility server
Shell
4
star
11

magiq

Turn query parameters into ActiveRecord scopes with a declarative interface
Ruby
4
star
12

personal-page

My personal site built with Ember+Prember hosted via GitHub pages ✨
JavaScript
3
star
13

propro-ansible

[UNSUPPORTED, OUTDATED] Ansible playbooks and roles for provisioning Ubuntu systems
Ruby
3
star
14

lcbo-cli

A command-line interface for interacting with LCBO API
3
star
15

glimmer-aptry

A first-try Glimmer implementation of the API explorer on LCBO API's homepage
CSS
2
star
16

openssl-key-truncation-workbench

A workspace to figure out if OpenSSL key truncation can be worked-around
Ruby
1
star