2.0.2-flat • Published 8 years ago
@flat/mailchecker v2.0.2-flat
MailChecker
Cross-language email validation. Backed by a database of 1987 throwable email providers.
- Validate the format of your email (uses validator.js email regex underneath and
FILTER_VALIDATE_EMAIL
for PHP) - Validate if the email is not a temporary mail (yopmail-like..., add your own dataset to list.json)
This will be very helpful when you have to contact your users and you want to avoid errors causing lack of communication or want to block "spamboxes".
Looking for a free Redis administration & monitoring service?
MailChecker currently supports:
- NodeJS (CommonJS)
- JavaScript (Client-Side)
- PHP
- Python
- Ruby
- Elixir
- Clojure
- Easily add support for your own language with MailChecker template system and send us a pull-request!
Usage
NodeJS
var MailChecker = require('mailchecker');
if(!MailChecker.is_valid('myemail@yopmail.com')){
console.error('O RLY !');
process.exit(1);
}
if(!MailChecker.is_valid('myemail.com')){
console.error('O RLY !');
process.exit(1);
}
JavaScript
<script type="text/javascript" src="MailChecker/platform/javascript/MailChecker.js"></script>
<script type="text/javascript">
if(!MailChecker.is_valid('myemail@yopmail.com')){
console.error('O RLY !');
}
if(!MailChecker.is_valid('myemail.com')){
console.error('O RLY !');
}
</script>
PHP
include __DIR__."/MailChecker/platform/php/MailChecker.php";
if(!MailChecker::isValid('myemail@yopmail.com')){
die('O RLY !');
}
if(!MailChecker::isValid('myemail.com')){
die('O RLY !');
}
Elixir
Code.require_file("mail_checker.ex", "mailchecker/platform/elixir/")
unless MailChecker.valid?("myemail@yopmail.com") do
raise "O RLY !"
end
unless MailChecker.valid?("myemail.com") do
raise "O RLY !"
end
Python
# no package yet; just drop in MailChecker.py where you want to use it.
import MailChecker
if not MailChecker.is_valid('bla@example.com'):
print "O RLY !"
Ruby
require 'mail_checker'
unless MailChecker('myemail@yopmail.com')
fail('O RLY!')
end
unless MailChecker.valid?('myemail@yopmail.com')
fail('O RLY!')
end
Clojure
; no package yet; just drop in mailchecker.clj where you want to use it.
(load-file "platform/clojure/mailchecker.clj")
(if (not (mailchecker/valid? "myemail@yopmail.com"))
(throw (Throwable. "O RLY!")))
(if (not (mailchecker/valid? "myemail.com"))
(throw (Throwable. "O RLY!")))
Installation
NodeJS/JavaScript
npm install mailchecker
Ruby
gem install ruby-mailchecker
We accept pull-requests for other package manager.
Data sources
$('td', 'table:last').map(function(){
return this.innerText;
}).toArray();
Array.prototype.slice.call(document.querySelectorAll('.entry > ul > li a')).map(function(el){return el.innerText});
... please add your own dataset to list.json.
Regenerate libraries from list.json
Just run (requires NodeJS):
npm run build
Donate
I maintain this project in my free time, if it helped you please support my work via paypal, thanks a lot!
Changelog
License
Copyright (c) Francois-Guillaume Ribreau Licensed under the MIT license.
2.0.2-flat
8 years ago