npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

canrfcemail

v0.0.3

Published

returns `true` for known valid addresses and returns `false` for some invalid email addresses.

Downloads

11

Readme

canrfcemail

(c)Bumblehead, 2014 MIT-license

OVERVIEW:

canrfcemail( email ) returns true for known valid addresses and returns false for some invalid email addresses.

No single email validation scheme works for everyone and each scheme makes compromises. Schemes differ by accuracy, speed and size. Authors of longer scripts claim they are more accurate. Some authors write scripts that are mostly accurate but are smaller and faster. Discussion threads on stackoverflow praise and criticise email validation schemes.

Links to RFC guidelines are found at the bottom of this wikipedia page.

This script has:

  1. MIT License

canrfcemail is commercially and freely usable. copy-lefted and un-licensed solutions are ignored. canrfcemail does not originate from those and is OK to use in your commercial application.

  1. Complete Test Suite

Test data is taken from this BSD licensed package, by Dominic Sayers. It includes 138 valid and 96 invalid email addresses. Run the tests and see the results of canrfcemail.

  1. false positive, OK. false negative, NOT OK.

Until a time when this script is 100% accurate, it must return true for all valid addresses. A consequence is that it will return true for many invalid addresses -considered an acceptable trade-off here and by anyone using this script.

When committing changes to the script, all tests for valid email addresses must pass.

  1. ECMAScript Agnostic

canrfcemail is usable as-is in a browser or node.js script environment.


Why

Its useful to show an error to a user that inputs an invalid email address.


Help is welcome

The goal: return true for all valid addresses and return false for as many invalid addresses as possible.

Any contributor to this script will be recognized as a primary author.

Help improve the results of current tests given below.

Use single commits that address specific parts of the rfc guideline.

This task is not well defined. Start with this wikipedia page, which includes links to related rfc documents when modifying this script.


Valid Emails 139/139, 100%

Each bold item represents a valid address canrfcemail returns true for. More bold items is better. Each item should be bold.

  1. canrfcemail('[email protected]');
  2. canrfcemail('[email protected]');
  3. canrfcemail('invalid');
  4. canrfcemail('ju^[email protected]');
  5. canrfcemail('[email protected]');
  6. canrfcemail('1234567890123456789012345678901234567890123456789012345678901234@iana.org');
  7. canrfcemail('"first"last"@iana.org');
  8. canrfcemail('1234567890123456789012345678901234567890123456789012345678@1234567890123456789012345678901234567890123456');
  9. canrfcemail('first.last@[12.34.56.78]');
  10. canrfcemail('first.last@[IPv6:::12.34.56.78]');
  11. canrfcemail('first.last@[IPv6:1111:2222:3333::4444:12.34.56.78]');
  12. canrfcemail('first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.56.78]');
  13. canrfcemail('first.last@[IPv6:::1111:2222:3333:4444:5555:6666]');
  14. canrfcemail('first.last@[IPv6:1111:2222:3333::4444:5555:6666]');
  15. canrfcemail('first.last@[IPv6:1111:2222:3333:4444:5555:6666::]');
  16. canrfcemail('first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888]');
  17. canrfcemail('first.last@x23456789012345678901234567890123456789012345678901234567890123.iana.org');
  18. canrfcemail('[email protected]');
  19. canrfcemail('[email protected]');
  20. canrfcemail('first.last@[IPv6:1111:2222:3333::4444:5555:12.34.56.78]');
  21. canrfcemail('first.last@[IPv6:1111:2222:3333::4444:5555:6666:7777]');
  22. canrfcemail('[email protected]');
  23. canrfcemail('first.last@com');
  24. canrfcemail('"Abc@def"@iana.org');
  25. canrfcemail('"Fred\ Bloggs"@iana.org');
  26. canrfcemail('"Joe.\Blow"@iana.org');
  27. canrfcemail('"Abc@def"@iana.org');
  28. canrfcemail('"Fred Bloggs"@iana.org');
  29. canrfcemail('[email protected]');
  30. canrfcemail('customer/[email protected]');
  31. canrfcemail('[email protected]');
  32. canrfcemail('!def!xyz%[email protected]');
  33. canrfcemail('[email protected]');
  34. canrfcemail('[email protected]');
  35. canrfcemail('[email protected]');
  36. canrfcemail('"Doug "Ace" L."@iana.org');
  37. canrfcemail('[email protected]');
  38. canrfcemail('[email protected]');
  39. canrfcemail('[email protected]');
  40. canrfcemail('[email protected]');
  41. canrfcemail('[email protected]');
  42. canrfcemail('t*[email protected]');
  43. canrfcemail('[email protected]');
  44. canrfcemail('{test}@iana.org');
  45. canrfcemail('"[[ test ]]"@iana.org');
  46. canrfcemail('[email protected]');
  47. canrfcemail('"test.test"@iana.org');
  48. canrfcemail('test."test"@iana.org');
  49. canrfcemail('"test@test"@iana.org');
  50. canrfcemail('[email protected]');
  51. canrfcemail('[email protected]');
  52. canrfcemail('test@[123.123.123.123]');
  53. canrfcemail('[email protected]');
  54. canrfcemail('[email protected]');
  55. canrfcemail('"test\test"@iana.org');
  56. canrfcemail('test@example');
  57. canrfcemail('"test"blah"@iana.org');
  58. canrfcemail('customer/[email protected]');
  59. canrfcemail('[email protected]');
  60. canrfcemail('[email protected]');
  61. canrfcemail('"Austin@Powers"@iana.org');
  62. canrfcemail('[email protected]');
  63. canrfcemail('"Ima.Fool"@iana.org');
  64. canrfcemail('"Ima Fool"@iana.org');
  65. canrfcemail('"first"."last"@iana.org');
  66. canrfcemail('"first".middle."last"@iana.org');
  67. canrfcemail('"first"[email protected]');
  68. canrfcemail('first."last"@iana.org');
  69. canrfcemail('"first"."middle"."last"@iana.org');
  70. canrfcemail('"first.middle"."last"@iana.org');
  71. canrfcemail('"first.middle.last"@iana.org');
  72. canrfcemail('"first..last"@iana.org');
  73. canrfcemail('"first\"last"@iana.org');
  74. canrfcemail('first."mid\dle"."last"@iana.org');
  75. canrfcemail('"test blah"@iana.org');
  76. canrfcemail('(foo)cal(bar)@(baz)iamcal.com(quux)');
  77. canrfcemail('cal@iamcal(woo).(yay)com');
  78. canrfcemail('cal(woo(yay)hoopla)@iamcal.com');
  79. canrfcemail('cal(foo@bar)@iamcal.com');
  80. canrfcemail('cal(foo)bar)@iamcal.com');
  81. canrfcemail('first()[email protected]');
  82. canrfcemail('pete(his account)@silly.test(his host)');
  83. canrfcemail("c@(Chris's host.)public.example");
  84. canrfcemail('jdoe@machine(comment). example');
  85. canrfcemail('1234 @ local(blah) .machine .example');
  86. canrfcemail('first(abc.def)[email protected]');
  87. canrfcemail('first(a"bc.def)[email protected]');
  88. canrfcemail('first.(")middle.last(")@iana.org');
  89. canrfcemail('first(abc(def)@iana.org');
  90. canrfcemail('first.last@x(1234567890123456789012345678901234567890123456789012345678901234567890).com');
  91. canrfcemail('a(a(b(c)d(e(f))g)h(i)j)@iana.org');
  92. canrfcemail('[email protected]');
  93. canrfcemail('a@b');
  94. canrfcemail('[email protected]');
  95. canrfcemail('aaa@[123.123.123.123]');
  96. canrfcemail('a@bar');
  97. canrfcemail('[email protected]');
  98. canrfcemail('[email protected]');
  99. canrfcemail('[email protected]');
  100. canrfcemail('[email protected]');
  101. canrfcemail('"hello my name is"@stutter.com');
  102. canrfcemail('"Test "Fail" Ing"@iana.org');
  103. canrfcemail('[email protected]');
  104. canrfcemail('[email protected]');
  105. canrfcemail('[email protected]');
  106. canrfcemail('"Joe\Blow"@iana.org');
  107. canrfcemail('HM2Kinsists@(that comments are allowed)this.is.ok');
  108. canrfcemail('user%[email protected]');
  109. canrfcemail('first.last @iana.org');
  110. canrfcemail("cdburgess+!#$%&'*-/=?+_{}|[email protected]");
  111. canrfcemail('first.last@[IPv6:::a2:a3:a4:b1:b2:b3:b4]');
  112. canrfcemail('first.last@[IPv6:a1:a2:a3:a4:b1:b2:b3::]');
  113. canrfcemail('first.last@[IPv6:::]');
  114. canrfcemail('first.last@[IPv6:::b4]');
  115. canrfcemail('first.last@[IPv6:::b3:b4]');
  116. canrfcemail('first.last@[IPv6:a1::b4]');
  117. canrfcemail('first.last@[IPv6:a1::]');
  118. canrfcemail('first.last@[IPv6:a1:a2::]');
  119. canrfcemail('first.last@[IPv6:0123:4567:89ab:cdef::]');
  120. canrfcemail('first.last@[IPv6:0123:4567:89ab:CDEF::]');
  121. canrfcemail('first.last@[IPv6:::a3:a4:b1:ffff:11.22.33.44]');
  122. canrfcemail('first.last@[IPv6:::a2:a3:a4:b1:ffff:11.22.33.44]');
  123. canrfcemail('"test\blah"@iana.org');
  124. canrfcemail('x@x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23456789.x23');
  125. canrfcemail('first.last@[IPv6:a1:a2:a3:a4::11.22.33.44]');
  126. canrfcemail('first.last@[IPv6:a1:a2:a3:a4:b1::11.22.33.44]');
  127. canrfcemail('first.last@[IPv6:a1::11.22.33.44]');
  128. canrfcemail('first.last@[IPv6:a1:a2::11.22.33.44]');
  129. canrfcemail('first.last@[IPv6:0123:4567:89ab:cdef::11.22.33.44]');
  130. canrfcemail('first.last@[IPv6:0123:4567:89ab:CDEF::11.22.33.44]');
  131. canrfcemail('first.last@[IPv6:a1::b2:11.22.33.44]');
  132. canrfcemail('[email protected]');
  133. canrfcemail('[email protected]');
  134. canrfcemail('[email protected]');
  135. canrfcemail('"first\last"@iana.org');
  136. canrfcemail('first@[email protected]');
  137. canrfcemail('abc@[email protected]');
  138. canrfcemail('[email protected]');

Invalid Emails 11/96, ~11%

Each bold item represents an invalid address canrfcemail returns false for. More bold items is better

  1. canrfcemail('[email protected],com');
  2. canrfcemail('123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234');
  3. canrfcemail('first.last');
  4. canrfcemail('12345678901234567890123456789012345678901234567890123456789012345@iana.org');
  5. canrfcemail('[email protected]');
  6. canrfcemail('[email protected]');
  7. canrfcemail('[email protected]');
  8. canrfcemail('"first"last"@iana.org');
  9. canrfcemail('"""@iana.org');
  10. canrfcemail('""@iana.org');
  11. canrfcemail('""@iana.org');
  12. canrfcemail('first.last@');
  13. canrfcemail('first.last@[.12.34.56.78]');
  14. canrfcemail('first.last@[12.34.56.789]');
  15. canrfcemail('first.last@[::12.34.56.78]');
  16. canrfcemail('first.last@[IPv5:::12.34.56.78]');
  17. canrfcemail('first.last@[IPv6:1111:2222:3333:4444:5555:12.34.56.78]');
  18. canrfcemail('first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:12.34.56.78]');
  19. canrfcemail('first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777]');
  20. canrfcemail('first.last@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999]');
  21. canrfcemail('first.last@[IPv6:1111:2222::3333::4444:5555:6666]');
  22. canrfcemail('first.last@[IPv6:1111:2222:333x::4444:5555]');
  23. canrfcemail('first.last@[IPv6:1111:2222:33333::4444:5555]');
  24. canrfcemail('[email protected]');
  25. canrfcemail('[email protected]');
  26. canrfcemail('first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org');
  27. canrfcemail('Doug\ "Ace"\ [email protected]');
  28. canrfcemail('abc@[email protected]');
  29. canrfcemail('@iana.org');
  30. canrfcemail('doug@');
  31. canrfcemail('"[email protected]');
  32. canrfcemail('ote"@iana.org');
  33. canrfcemail('[email protected]');
  34. canrfcemail('[email protected]');
  35. canrfcemail('[email protected]');
  36. canrfcemail('"Doug "Ace" L."@iana.org');
  37. canrfcemail('Doug\ "Ace"\ [email protected]');
  38. canrfcemail('hello [email protected]');
  39. canrfcemail('[email protected].');
  40. canrfcemail('test.iana.org');
  41. canrfcemail('[email protected]');
  42. canrfcemail('[email protected]');
  43. canrfcemail('[email protected]');
  44. canrfcemail('test@[email protected]');
  45. canrfcemail('test@@iana.org');
  46. canrfcemail('-- test [email protected]');
  47. canrfcemail('[test]@iana.org');
  48. canrfcemail('"test"test"@iana.org');
  49. canrfcemail('()[];:,>');
  50. canrfcemail('test@.');
  51. canrfcemail('test@example.');
  52. canrfcemail('[email protected]');
  53. canrfcemail('test@1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
  54. canrfcemail('test@[123.123.123.123');
  55. canrfcemail('[email protected]]');
  56. canrfcemail('NotAnEmail');
  57. canrfcemail('@NotAnEmail');
  58. canrfcemail('"test"blah"@iana.org');
  59. canrfcemail('[email protected]');
  60. canrfcemail('[email protected]');
  61. canrfcemail('[email protected]');
  62. canrfcemail('[email protected]');
  63. canrfcemail('Ima [email protected]');
  64. canrfcemail('phil.h@@[email protected]');
  65. canrfcemail('foo@[\1.2.3.4]');
  66. canrfcemail('first.""[email protected]');
  67. canrfcemail('first\[email protected]');
  68. canrfcemail('Abc@[email protected]');
  69. canrfcemail('Fred\ [email protected]');
  70. canrfcemail('Joe.\[email protected]');
  71. canrfcemail('first.last@[IPv6:1111:2222:3333:4444:5555:6666:12.34.567.89]');
  72. canrfcemail('{^c@**Dog^}@cartoon.com');
  73. canrfcemail('"foo"(yay)@(hoopla)[1.2.3.4]');
  74. canrfcemail('cal(foo(bar)@iamcal.com');
  75. canrfcemail('cal(foo)bar)@iamcal.com');
  76. canrfcemail('cal(foo)@iamcal.com');
  77. canrfcemail('first(12345678901234567890123456789012345678901234567890)last@(123456789012345678901234567890123456789012');
  78. canrfcemail('first(middle)[email protected]');
  79. canrfcemail('first(abc("def".ghi).mno)middle(abc("def".ghi).mno).last@(abc("def".ghi).mno)example(abc("def".ghi).mno).');
  80. canrfcemail('a(a(b(c)d(e(f))g)(h(i)j)@iana.org');
  81. canrfcemail('.@');
  82. canrfcemail('@bar.com');
  83. canrfcemail('@@bar.com');
  84. canrfcemail('aaa.com');
  85. canrfcemail('[email protected]');
  86. canrfcemail('[email protected]');
  87. canrfcemail('aaa@[123.123.123.123]a');
  88. canrfcemail('aaa@[123.123.123.333]');
  89. canrfcemail('[email protected].');
  90. canrfcemail('[email protected]');
  91. canrfcemail('[email protected]');
  92. canrfcemail('[email protected]');
  93. canrfcemail('[email protected]');
  94. canrfcemail('[email protected]');
  95. canrfcemail('[email protected]');
  96. canrfcemail('"Unicode NULL');

Install:

canrfcemail may be downloaded directly or installed through npm.

  • npm
$ npm install canrfcemail
  • Direct Download
$ git clone https://github.com/iambumblehead/canrfcemail.git

Test:

to run tests, use npm test from a shell.

$ npm test

License:

scrounge

(The MIT License)

Copyright (c) 2014 Bumblehead [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

(The BSD License), Here