Git Product home page Git Product logo

email-address-validator's Introduction

Email Address Validator

Like any data, an e-mail address that you accept from a user cannot just be accepted at face value, it needs to be validated. It's non-trivial to do this, though -- not only do you have to make sure that it is formatted correctly (and this is harder than it first appears, as the rules for what constitute a valid e-mail address aren't simple), you also have to make sure that the e-mail address will actually receive mail.

The EmailAddressValidator class tries, as much as possible without actually delivering an e-mail, to validate that an e-mail address is valid and will accept e-mail. It does this in three stages:

  • Ensure that the e-mail address is correctly formatted, using a regular expression derived from the ABNF specified in RFC2822 for maximum correctness. This takes very little resources.

  • Lookup MX records or A records for the domain part of the e-mail address, to make sure that there's someone who might be willing to receive mail. This lookup requires network access and take a little bit of time, but can catch a lot of simple typos.

  • Make an attempt to deliver an e-mail to the address, stopping just before sending the message body. This is the most accurate way to discover whether an e-mail will be delivered, although it is still not 100% accurate (for example, Exchange servers will accept all mail at SMTP time and then generate a bounce, so an SMTP-time test won't tell you anything useful there). However, most e-mail services will do the right thing, and it is the only way to detect a typo'd local part. It does take a little while to perform this lookup, though.

See the rdoc/ri documentation for full information on how to use this class, or just look in lib/email_address_validator/email_address_validator.rb.

email-address-validator's People

Contributors

mpalmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.