{"id":13878949,"url":"https://github.com/afair/email_address","last_synced_at":"2025-07-16T15:30:32.689Z","repository":{"id":8138066,"uuid":"9556361","full_name":"afair/email_address","owner":"afair","description":"The EmailAddress Gem to work with and validate email addresses.","archived":false,"fork":false,"pushed_at":"2023-10-12T12:31:01.000Z","size":347,"stargazers_count":314,"open_issues_count":6,"forks_count":54,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-08T01:54:17.551Z","etag":null,"topics":["email-address","email-validation","parser","ruby","ruby-gem","validator"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afair.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-04-19T23:20:59.000Z","updated_at":"2024-08-23T09:45:09.000Z","dependencies_parsed_at":"2024-01-13T20:56:24.565Z","dependency_job_id":"5257c053-b85c-4ccb-901e-50c620f0994c","html_url":"https://github.com/afair/email_address","commit_stats":{"total_commits":207,"total_committers":20,"mean_commits":10.35,"dds":"0.24154589371980673","last_synced_commit":"3942c25a060dcf008e2273651f55d0eff03b0a67"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afair%2Femail_address","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afair%2Femail_address/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afair%2Femail_address/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afair%2Femail_address/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afair","download_url":"https://codeload.github.com/afair/email_address/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email-address","email-validation","parser","ruby","ruby-gem","validator"],"created_at":"2024-08-06T08:02:05.153Z","updated_at":"2024-11-24T07:31:25.913Z","avatar_url":"https://github.com/afair.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Email Address\n\n[![Gem Version](https://badge.fury.io/rb/email_address.svg)](http://rubygems.org/gems/email_address)\n[![CI Build](https://github.com/afair/email_address/actions/workflows/ci.yml/badge.svg)](https://github.com/afair/email_address/actions/workflows/ci.yml)\n[![Code Climate](https://codeclimate.com/github/afair/email_address/badges/gpa.svg)](https://codeclimate.com/github/afair/email_address)\n\nThe `email_address` gem provides a ruby language library for working\nwith email addresses.\n\nBy default, it validates against conventional usage,\nthe format preferred for user email addresses.\nIt can be configured to validate against RFC \"Standard\" formats,\ncommon email service provider formats, and perform DNS validation.\n\nUsing `email_address` to validate user email addresses results in\nfewer \"false positives\" due to typing errors and gibberish data.\nIt validates syntax more strictly for popular email providers,\nand can deal with gmail's \"optional dots\" in addresses.\n\nIt provides Active Record (Rails) extensions, including an\naddress validator and attributes API custom datatypes.\n\nRequires Ruby 2.0 or later.\n\nLooking for a Javascript version of this library? Check out the\n[email_address](https://www.npmjs.com/package/email_address) npm module.\n\n## Quick Start\n\nTo quickly validate email addresses, use the valid? and error helpers.\n`valid?` returns a boolean, and `error` returns nil if valid, otherwise\na basic error message.\n\n```ruby\nEmailAddress.valid? \"allen@google.com\" #=\u003e true\nEmailAddress.error \"allen@bad-d0main.com\" #=\u003e \"Invalid Host/Domain Name\"\n```\n\n`EmailAddress` deeply validates your email addresses. It checks:\n\n* Host name format and DNS setup\n* Mailbox format according to \"conventional\" form. This matches most used user\n  email accounts, but is a subset of the RFC specification.\n\nIt does not check:\n\n* The mail server is configured to accept connections\n* The mailbox is valid and accepts email.\n\nBy default, MX records are required in DNS. MX or \"mail exchanger\" records\ntell where to deliver email for the domain. Many domains run their\nwebsite on one provider (ISP, Heroku, etc.), and email on a different\nprovider (such as G Suite).  Note that `example.com`, while\na valid domain name, does not have MX records.\n\n```ruby\nEmailAddress.valid? \"allen@example.com\" #=\u003e false\nEmailAddress.valid? \"allen@example.com\", host_validation: :syntax #=\u003e true\n```\n\nMost mail servers do not yet support Unicode mailboxes, so the default here is ASCII.\n\n```ruby\nEmailAddress.error \"Pelé@google.com\" #=\u003e \"Invalid Recipient/Mailbox\"\nEmailAddress.valid? \"Pelé@google.com\", local_encoding: :unicode #=\u003e true\n```\n\n## Background\n\nThe email address specification is complex and often not what you want\nwhen working with personal email addresses in applications. This library\nintroduces terms to distinguish types of email addresses.\n\n* *Normal* - The edited form of any input email address. Typically, it\n  is lower-cased and minor \"fixes\" can be performed, depending on the\n  configurations and email address provider.\n\n    CKENT@DAILYPLANET.NEWS =\u003e ckent@dailyplanet.news\n\n* *Conventional* - Most personal account addresses are in this basic\n  format, one or more \"words\" separated by a single simple punctuation\n  character. It consists of a mailbox (user name or role account) and\n  an optional address \"tag\" assigned by the user.\n\n    miles.o'brien@ncc-1701-d.ufp\n\n* *Relaxed* - A less strict form of Conventional, same character set,\n  must begin and end with an alpha-numeric character, but order within\n  is not enforced.\n\n    aasdf-34-.z@example.com\n\n* *Standard* - The RFC-Compliant syntax of an email address. This is\n  useful when working with software-generated addresses or handling\n  existing email addresses, but otherwise not useful for personal\n  addresses.\n\n    madness!.\"()\u003c\u003e[]:,;@\\\\\\\"!#$%\u0026'*+-/=?^_`{}| ~.a(comment )\"@example.org\n\n* *Base* - A unique mailbox without tags. For gmail, is uses the incoming\n  punctation, essential when building an MD5, SHA1, or SHA256 to match services\n  like Gravatar, and email address digest interchange.\n\n* *Canonical* - An unique account address, lower-cased, without the\n  tag, and with irrelevant characters stripped.\n\n    clark.kent+scoops@gmail.com =\u003e clarkkent@gmail.com\n\n* *Reference* - The MD5 of the Base format, used to share account\n  references without exposing the private email address directly.\n\n    Clark.Kent+scoops@gmail.com =\u003e\n    clark.kent@gmail.com =\u003e 1429a1dfc797d6e93075fef011c373fb\n\n* *Redacted* - A form of the email address where it is replaced by\n  a SHA1-based version to remove the original address from the\n  database, or to store the address privately, yet still keep it\n  accessible at query time by converting the queried address to\n  the redacted form.\n\n    Clark.Kent+scoops@gmail.com =\u003e {bea3f3560a757f8142d38d212a931237b218eb5e}@gmail.com\n\n* *Munged* - An obfuscated version of the email address suitable for\n  publishing on the internet, where email address harvesting\n  could occur.\n\n    Clark.Kent+scoops@gmail.com =\u003e cl\\*\\*\\*\\*\\*@gm\\*\\*\\*\\*\\*\n\nOther terms:\n\n* *Local* - The left-hand side of the \"@\", representing the user,\n  mailbox, or role, and an optional \"tag\".\n\n    mailbox+tag@example.com;   Local part: mailbox+tag\n\n* *Mailbox* - The destination user account or role account.\n* *Tag* - A parameter added after the mailbox, usually after the\n  \"+\" symbol, set by the user for mail filtering and sub-accounts.\n  Not all mail systems support this.\n* *Host* (sometimes called *Domain*) - The right-hand side of the \"@\"\n  indicating the domain or host name server to delivery the email.\n  If missing, \"localhost\" is assumed, or if not a fully-qualified\n  domain name, it assumed another computer on the same network, but\n  this is increasingly rare.\n* *Provider* - The Email Service Provider (ESP) providing the email\n  service. Each provider may have its own email address validation\n  and canonicalization rules.\n* *Punycode* - A host name with Unicode characters (International\n  Domain Name or IDN) needs conversion to this ASCII-encoded format\n  for DNS lookup.\n\n    \"HIRO@こんにちは世界.com\" =\u003e \"hiro@xn--28j2a3ar1pp75ovm7c.com\"\n\nWikipedia has a great article on\n[Email Addresses](https://en.wikipedia.org/wiki/Email_address),\nmuch more readable than the section within\n[RFC 5322](https://tools.ietf.org/html/rfc5322#section-3.4)\n\n## Avoiding the Bad Parts of RFC Specification\n\nFollowing the RFC specification sounds like a good idea, until you\nlearn about all the madness contained therein. This library can\nvalidate the RFC syntax, but this is never useful, especially when\nvalidating user email address submissions. By default, it validates\nto the *conventional* format.\n\nHere are a few parts of the RFC specification you should avoid:\n\n* Case-sensitive local parts: `First.Last@example.com`\n* Spaces and Special Characters: `\"():;\u003c\u003e@[\\\\]`\n* Quoting and Escaping Requirements: `\"first \\\"nickname\\\" last\"@example.com`\n* Comment Parts: `(comment)mailbox@example.com`\n* IP and IPv6 addresses as hosts: `mailbox@[127.0.0.1]`\n* Non-ASCII (7-bit) characters in the local part: `Pelé@example.com`\n* Validation by voodoo regular expressions\n* Gmail allows \"..\" in addresses since they are not meaningful, but\n  the standard does not.\n\n## Installation With Rails or Bundler\n\nIf you are using Rails or a project with Bundler, add this line to your application's Gemfile:\n\n    gem 'email_address'\n\nAnd then execute:\n\n    $ bundle\n\n## Installation Without Bundler\n\nIf you are not using Bundler, you need to install the gem yourself.\n\n    $ gem install email_address\n\nRequire the gem inside your script.\n\n```ruby\nrequire 'rubygems'\nrequire 'email_address'\n```\n\n## Usage\n\nUse `EmailAddress` to do transformations and validations. You can also\ninstantiate an object to inspect the address.\n\nThese top-level helpers return edited email addresses and validation\ncheck.\n\n```ruby\naddress = \"Clark.Kent+scoops@gmail.com\"\nEmailAddress.valid?(address)    #=\u003e true\nEmailAddress.normal(address)    #=\u003e \"clark.kent+scoops@gmail.com\"\nEmailAddress.canonical(address) #=\u003e \"clarkkent@gmail.com\"\nEmailAddress.reference(address) #=\u003e \"c5be3597c391169a5ad2870f9ca51901\"\nEmailAddress.redact(address)    #=\u003e \"{bea3f3560a757f8142d38d212a931237b218eb5e}@gmail.com\"\nEmailAddress.munge(address)     #=\u003e \"cl*****@gm*****\"\nEmailAddress.matches?(address, 'google') #=\u003e 'google' (true)\nEmailAddress.error(\"#bad@example.com\") #=\u003e \"Invalid Mailbox\"\n```\n\nOr you can create an instance of the email address to work with it.\n\n```ruby\nemail = EmailAddress.new(address) #=\u003e #\u003cEmailAddress::Address:0x007fe6ee150540 ...\u003e\nemail.normal        #=\u003e \"clark.kent+scoops@gmail.com\"\nemail.canonical     #=\u003e \"clarkkent@gmail.com\"\nemail.original      #=\u003e \"Clark.Kent+scoops@gmail.com\"\nemail.valid?        #=\u003e true\n```\n\nHere are some other methods that are available.\n\n```ruby\nemail.redact        #=\u003e \"{bea3f3560a757f8142d38d212a931237b218eb5e}@gmail.com\"\nemail.sha1          #=\u003e \"bea3f3560a757f8142d38d212a931237b218eb5e\"\nemail.sha256        #=\u003e \"9e2a0270f2d6778e5f647fc9eaf6992705ca183c23d1ed1166586fd54e859f75\"\nemail.md5           #=\u003e \"c5be3597c391169a5ad2870f9ca51901\"\nemail.host_name     #=\u003e \"gmail.com\"\nemail.provider      #=\u003e :google\nemail.mailbox       #=\u003e \"clark.kent\"\nemail.tag           #=\u003e \"scoops\"\n\nemail.host.exchangers.first[:ip] #=\u003e \"2a00:1450:400b:c02::1a\"\nemail.host.txt_hash #=\u003e {:v=\u003e\"spf1\", :redirect=\u003e\"\\_spf.google.com\"}\n\nEmailAddress.normal(\"HIRO@こんにちは世界.com\")\n                    #=\u003e \"hiro@xn--28j2a3ar1pp75ovm7c.com\"\nEmailAddress.normal(\"hiro@xn--28j2a3ar1pp75ovm7c.com\", host_encoding: :unicode)\n                    #=\u003e \"hiro@こんにちは世界.com\"\n```\nAs of release 0.1.17, exchanger_match is no longer used for host provider\ndetermination, which designated the set of rules for that domain.\nSometimes, as in Google-hosted domains, the address\nrules are different, notably the optional dots in mailboxes for gmail.com\naccounts do not apply to other private domains hosted at google.\n\nTo access the provider service, you can now call:\n\n    EmailAddress.new(\"user@hosteddomain.com\").host.hosted_provider\n\n\n#### Rails Validator\n\nFor Rails' ActiveRecord classes, EmailAddress provides an ActiveRecordValidator.\nSpecify your email address attributes with `field: :user_email`, or\n`fields: [:email1, :email2]`. If neither is given, it assumes to use the\n`email` or `email_address` attribute.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  validates_with EmailAddress::ActiveRecordValidator, field: :email\nend\n```\n\n#### Rails I18n\n\nCopy and adapt `lib/email_address/messages.yaml` into your locales and\ncreate an after initialization callback:\n\n```ruby\n# config/initializers/email_address.rb\n\nRails.application.config.after_initialize do\n  I18n.available_locales.each do |locale|\n    translations = I18n.t(:email_address, locale: locale)\n\n    next unless translations.is_a? Hash\n\n    EmailAddress::Config.error_messages translations.transform_keys(\u0026:to_s), locale.to_s\n  end\nend\n```\n\n#### Rails Email Address Type Attribute\n\nInitial support is provided for Active Record 5.0 attributes API.\n\nFirst, you need to register the type in\n`config/initializers/email_address.rb` along with any global\nconfigurations you want.\n\n```ruby\nActiveRecord::Type.register(:email_address, EmailAddress::EmailAddressType)\nActiveRecord::Type.register(:canonical_email_address,\n                            EmailAddress::CanonicalEmailAddressType)\n```\n\nAssume the Users table contains the columns \"email\" and \"canonical_email\".\nWe want to normalize the address in \"email\" and store the canonical/unique\nversion in \"canonical_email\". This code will set the canonical_email when\nthe email attribute is assigned. With the canonical_email column,\nwe can look up the User, even it the given email address didn't exactly\nmatch the registered version.\n\n```ruby\nclass User \u003c ApplicationRecord\n  attribute :email, :email_address\n  attribute :canonical_email, :canonical_email_address\n\n  validates_with EmailAddress::ActiveRecordValidator,\n                 fields: %i(email canonical_email)\n\n  def email=(email_address)\n    self[:canonical_email] = email_address\n    self[:email] = email_address\n  end\n\n  def self.find_by_email(email)\n    user   = self.find_by(email: EmailAddress.normal(email))\n    user ||= self.find_by(canonical_email: EmailAddress.canonical(email))\n    user ||= self.find_by(canonical_email: EmailAddress.redacted(email))\n    user\n  end\n\n  def redact!\n    self[:canonical_email] = EmailAddress.redact(self.canonical_email)\n    self[:email]           = self[:canonical_email]\n  end\nend\n```\n\nHere is how the User model works:\n\n```ruby\nuser = User.create(email:\"Pat.Smith+registrations@gmail.com\")\nuser.email           #=\u003e \"pat.smith+registrations@gmail.com\"\nuser.canonical_email #=\u003e \"patsmith@gmail.com\"\nUser.find_by_email(\"PAT.SMITH@GMAIL.COM\")\n                     #=\u003e #\u003cUser email=\"pat.smith+registrations@gmail.com\"\u003e\n```\n\nThe `find_by_email` method looks up a given email address by the\nnormalized form (lower case), then by the canonical form, then finally\nby the redacted form.\n\n#### Validation\n\nThe only true validation is to send a message to the email address and\nhave the user (or process) verify it has been received. Syntax checks\nhelp prevent erroneous input. Even sent messages can be silently\ndropped, or bounced back after acceptance.  Conditions such as a\n\"Mailbox Full\" can mean the email address is known, but abandoned.\n\nThere are different levels of validations you can perform. By default, it will\nvalidate to the \"Provider\" (if known), or \"Conventional\" format defined as the\n\"default\" provider. You may pass a a list of parameters to select\nwhich syntax and network validations to perform.\n\n#### Comparison\n\nYou can compare email addresses:\n\n```ruby\ne1 = EmailAddress.new(\"Clark.Kent@Gmail.com\")\ne2 = EmailAddress.new(\"clark.kent+Superman@Gmail.com\")\ne3 = EmailAddress.new(e2.redact)\ne1.to_s           #=\u003e \"clark.kent@gmail.com\"\ne2.to_s           #=\u003e \"clark.kent+superman@gmail.com\"\ne3.to_s           #=\u003e \"{bea3f3560a757f8142d38d212a931237b218eb5e}@gmail.com\"\n\ne1 == e2          #=\u003e false (Matches by normalized address)\ne1.same_as?(e2)   #=\u003e true  (Matches as canonical address)\ne1.same_as?(e3)   #=\u003e true  (Matches as redacted address)\ne1 \u003c e2           #=\u003e true  (Compares using normalized address)\n```\n\n#### Matching\n\nMatching addresses by simple patterns:\n\n   * Top-Level-Domain:         .org\n   * Domain Name:              example.com\n   * Registration Name:        hotmail.   (matches any TLD)\n   * Domain Glob:              *.exampl?.com\n   * Provider Name:            google\n   * Mailbox Name or Glob:     user00*@\n   * Address or Glob:          postmaster@domain*.com\n   * Provider or Registration: msn\n\nUsage:\n\n```ruby\ne = EmailAddress.new(\"Clark.Kent@Gmail.com\")\ne.matches?(\"gmail.com\") #=\u003e true\ne.matches?(\"google\")    #=\u003e true\ne.matches?(\".org\")      #=\u003e false\ne.matches?(\"g*com\")     #=\u003e true\ne.matches?(\"gmail.\")    #=\u003e true\ne.matches?(\"*kent*@\")   #=\u003e true\n```\n\n### Configuration\n\nYou can pass an options hash on the `.new()` and helper class methods to\ncontrol how the library treats that address. These can also be\nconfigured during initialization by provider and default (see below).\n\n```ruby\nEmailAddress.new(\"clark.kent@gmail.com\",\n                 host_validation: :syntax, host_encoding: :unicode)\n```\n\nGlobally, you can change and query configuration options:\n\n```ruby\nEmailAddress::Config.setting(:host_validation, :mx)\nEmailAddress::Config.setting(:host_validation) #=\u003e :mx\n```\n\nOr set multiple settings at once:\n\n```ruby\nEmailAddress::Config.configure(local_downcase: false, host_validation: :syntax)\n```\n\nYou can add special rules by domain or provider. It takes the options\nabove and adds the :domain_match and :exchanger_match rules.\n\n```ruby\nEmailAddress.define_provider('google',\n  domain_match:      %w(gmail.com googlemail.com),\n  exchanger_match:   %w(google.com), # Requires host_validation==:mx\n  local_size:        5..64,\n  mailbox_canonical: -\u003e(m) {m.gsub('.','')})\n```\n\nThe library ships with the most common set of provider rules. It is not meant\nto house a database of all providers, but a separate `email_address-providers`\ngem may be created to hold this data for those who need more complete rules.\n\nPersonal and Corporate email systems are not intended for either solution.\nAny of these email systems may be configured locally.\n\nPre-configured email address providers include: Google (gmail), AOL, MSN\n(hotmail, live, outlook), and Yahoo. Any address not matching one of\nthose patterns use the \"default\" provider rule set. Exchanger matches\nmatches against the Mail Exchanger (SMTP receivers) hosts defined in\nDNS. If you specify an exchanger pattern, but requires a DNS MX lookup.\n\nFor Rails application, create an initializer file with your default\nconfiguration options.\nEmailAddress::Config.setting takes a single setting name and value,\nwhile EmailAddress::Config.configure takes a hash of multiple settings.\n\n```ruby\n# ./config/initializers/email_address.rb\nEmailAddress::Config.setting( :local_format, :relaxed )\nEmailAddress::Config.configure( local_format: :relaxed, ... )\nEmailAddress::Config.provider(:github,\n       host_match: %w(github.com), local_format: :standard)\n```\n\n#### Override Error Messaegs\n\nYou can override the default error messages as follows:\n\n```ruby\nEmailAddress::Config.error_messages({\n  invalid_address:    \"Invalid Email Address\",\n  invalid_mailbox:    \"Invalid Recipient/Mailbox\",\n  invalid_host:       \"Invalid Host/Domain Name\",\n  exceeds_size:       \"Address too long\",\n  not_allowed:        \"Address is not allowed\",\n  incomplete_domain:  \"Domain name is incomplete\"}, 'en')\n```\nNote: Release 0.1.14 fixed setting error messages by locale.\nAlso, it will accept a ruby \"collected\" hash as before,\n\nFull translation support would be ideal though.\n\n### Available Configuration Settings\n\n* sha1_secret -\n  This application-level secret is appended to the email_address to compute\n  the SHA1 Digest, making it unique to your application so it can't easily be\n  discovered by comparing against a known list of email/sha1 pairs.\n\n* sha256_secret -\n  This application-level secret is appended to the email_address to compute\n  the SHA256 Digest, making it unique to your application so it can't easily be\n  discovered by comparing against a known list of email/sha256 pairs.\n\n* munge_string - \"*****\", the string to replace into munged addresses.\n\nFor local part configuration:\n\n* local_downcase: true.\n  Downcase the local part. You probably want this for uniqueness.\n  RFC says local part is case insensitive, that's a bad part.\n\n* local_fix:  true.\n  Make simple fixes when available, remove spaces, condense multiple punctuations\n\n* local_encoding:     :ascii, :unicode,\n  Enable Unicode in local part. Most mail systems do not yet support this.\n  You probably want to stay with ASCII for now.\n\n* local_parse:        nil, -\u003e(local) { [mailbox, tag, comment] }\n  Specify an optional lambda/Proc to parse the local part. It should return an\n  array (tuple) of mailbox, tag, and comment.\n\n* local_format:\n    * :conventional - word ( puncuation{1} word )*\n    * :relaxed      - alphanum ( allowed_characters)* alphanum\n    * :standard     - RFC Compliant email addresses (anything goes!)\n\n* local_size:         1..64,\n  A Range specifying the allowed size for mailbox + tags + comment\n\n* tag_separator:      nil, character (+)\n  Nil, or a character used to split the tag from the mailbox\n\nFor the mailbox (AKA account, role), without the tag\n* mailbox_size:       1..64\n  A Range specifying the allowed size for mailbox\n\n* mailbox_canonical:  nil, -\u003e(mailbox) { mailbox }\n  An optional lambda/Proc taking a mailbox name, returning a canonical\n  version of it. (E.G.: gmail removes '.' characters)\n\n* mailbox_validator:  nil, -\u003e(mailbox) { true }\n  An optional lambda/Proc taking a mailbox name, returning true or false.\n\n* host_encoding:      :punycode,  :unicode,\n  How to treat International Domain Names (IDN). Note that most mail and\n  DNS systems do not support unicode, so punycode needs to be passed.\n  :punycode           Convert Unicode names to punycode representation\n  :unicode            Keep Unicode names as is.\n\n* host_validation:\n  :mx                 Ensure host is configured with DNS MX records\n  :a                  Ensure host is known to DNS (A Record)\n  :syntax             Validate by syntax only, no Network verification\n  :connect            Attempt host connection (Experimental and Dangerous: Do not use)\n                      The :host_timeout setting is the maximum number\n                      of seconds to wait during the :connect validation\n\n* host_size:          1..253,\n  A range specifying the size limit of the host part,\n\n* host_allow_ip:      false,\n  Allow IP address format in host: [127.0.0.1], [IPv6:::1]\n\n* address_validation: :parts, :smtp, -\u003e(address) { true }\n  Address validation policy\n  :parts              Validate local and host.\n  :smtp               Validate via SMTP (not implemented, BAD!)\n  A lambda/Proc taking the address string, returning true or false\n\n* address_size:       3..254,\n  A range specifying the size limit of the complete address\n\nFor provider rules to match to domain names and Exchanger hosts\nThe value is an array of match tokens.\n* host_match:         %w(.org example.com hotmail. user*@ sub.*.com)\n* exchanger_match:    %w(google.com 127.0.0.1 10.9.8.0/24 ::1/64)\n\n### Namespace conflict resolution\n\nIf your application already uses the `EmailAddress` class name,\nit's possible to create an alias prior to loading your code:\n\nFor a Rails application, you can do this in `config/application.rb`\nafter the `Bundler.require` line, usually:\n\n```ruby\nBundler.require(*Rails.groups)\n```\n\nAdd these lines immediately after that point:\n\n```ruby\nEmailAddressValidator = EmailAddress\nObject.send(:remove_const, :EmailAddress)\n```\n\nThen your application loads with your EmailAddress class. You may\nthen use this gem with `EmailAddressValidator` or whatever name you\ngave it above:\n\n```ruby\nEmailAddressValidator.valid?(\"clark.kent@gmail.com\") # =\u003e true\n```\n\n## Notes\n\n#### Internationalization\n\nThe industry is moving to support Unicode characters in the local part\nof the email address. Currently, SMTP supports only 7-bit ASCII, but a\nnew `SMTPUTF8` standard is available, but not yet widely implemented.\nTo work properly, global Email systems must be converted to UTF-8\nencoded databases and upgraded to the new email standards.\n\nThe problem with i18n email addresses is that support outside of the\ngiven locale becomes hard to enter addresses on keyboards for another\nlocale. Because of this, internationalized local parts are not yet\nsupported by default. They are more likely to be erroneous.\n\nProper personal identity can still be provided using\n[MIME Encoded-Words](http://en.wikipedia.org/wiki/MIME#Encoded-Word)\nin Email headers.\n\n#### Email Addresses as Sensitive Data\n\nLike Social Security and Credit Card Numbers, email addresses are\nbecoming more important as a personal identifier on the internet.\nIncreasingly, we should treat email addresses as sensitive data. If your\nsite/database becomes compromised by hackers, these email addresses can\nbe stolen and used to spam your users and to try to gain access to their\naccounts. You should not be storing passwords in plain text; perhaps you\ndon't need to store email addresses un-encoded either.\n\nConsider this: upon registration, store the redacted email address for\nthe user, and of course, the salted, encrypted password.\nWhen the user logs in, compute the redacted email address from\nthe user-supplied one and look up the record. Store the original address\nin the session for the user, which goes away when the user logs out.\n\nSometimes, users demand you strike their information from the database.\nInstead of deleting their account, you can \"redact\" their email\naddress, retaining the state of the account to prevent future\naccess. Given the original email address again, the redacted account can\nbe identified if necessary.\n\nBecause of these use cases, the **redact** method on the email address\ninstance has been provided.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n#### Project\n\nThis project lives at [https://github.com/afair/email_address/](https://github.com/afair/email_address/)\n\n#### Authors\n\n* [Allen Fair](https://github.com/afair) ([@allenfair](https://twitter.com/allenfair)):\n  I've worked with email-based applications and email addresses since 1999.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafair%2Femail_address","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafair%2Femail_address","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafair%2Femail_address/lists"}