email_verifier 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +20 -18
- data/email_verifier.gemspec +1 -0
- data/lib/email_verifier.rb +10 -0
- data/lib/email_verifier/checker.rb +2 -0
- data/lib/email_verifier/validates_email_realness.rb +4 -4
- data/lib/email_verifier/version.rb +1 -1
- data/locales/en.yml +8 -0
- data/locales/pl.yml +8 -0
- metadata +8 -6
- data/rails/init.rb +0 -1
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
[](http://badge.fury.io/rb/email_verifier)
|
1
2
|
# Email Verifier
|
2
3
|
|
3
|
-
Helper validation utility for checking
|
4
|
-
Many times as developers we've put in our models statements for checking email address
|
5
|
-
*format*. This gem will complete your existing setups with validator that actually
|
6
|
-
connects with given mail server and asks if given email address exists for real.
|
4
|
+
Helper validation utility for checking if given email address is real.
|
7
5
|
|
8
|
-
**
|
6
|
+
Many times as developers we were putting validation statements for checking email addresses *format*. This gem will **complete** your existing setups with validator that actually connects with a given mail server and asks if the address in question exists for real.
|
7
|
+
|
8
|
+
It also:
|
9
|
+
|
10
|
+
* supports Heroku
|
11
|
+
* supports localization
|
9
12
|
|
10
13
|
## Installation
|
11
14
|
|
@@ -23,12 +26,9 @@ Or install it yourself as:
|
|
23
26
|
|
24
27
|
## Usage
|
25
28
|
|
26
|
-
To get info about realness of given email address, email_verifier connects
|
27
|
-
with mail server that email's domain points to and pretends to send an email.
|
29
|
+
To get info about realness of given email address, email_verifier connects with a mail server that email's domain points to and pretends to send an email. Some smtp servers will not allow you to do this if you will not present yourself as a real user.
|
28
30
|
|
29
|
-
|
30
|
-
yourself as some real user. So first thing you'd need to set up is to
|
31
|
-
put something like this either in initializer or in application.rb file:
|
31
|
+
First thing you need to set up is placing something like this either in initializer or in application.rb file:
|
32
32
|
|
33
33
|
EmailVerifier.config do |config|
|
34
34
|
config.verifier_email = "realname@realdomain.com"
|
@@ -40,21 +40,23 @@ Then just put this in your model e. g:
|
|
40
40
|
|
41
41
|
Or - if you'd like to use it outside of your models:
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
This method will return true or false, or - will throw exception
|
46
|
-
with nicely detailed info about what's wrong.
|
43
|
+
EmailVerifier.check(youremail)
|
47
44
|
|
48
|
-
|
45
|
+
This method will return true or false, or will throw an exception with nicely detailed info about what's wrong.
|
49
46
|
|
50
47
|
## Credits
|
51
|
-

|
48
|
+

|
52
49
|
|
53
|
-
Email Verifier is maintained and funded by [End Point Corporation](http://www.endpoint.com/)
|
50
|
+
Email Verifier is maintained and funded by the [End Point Corporation](http://www.endpoint.com/)
|
54
51
|
|
55
52
|
Please send questions to [kamil@endpoint.com](mailto:kamil@endpoint.com)
|
56
53
|
|
57
|
-
##
|
54
|
+
## Contributors
|
55
|
+
|
56
|
+
* Maciej Walusiak ([https://github.com/Rabsztok]())
|
57
|
+
* Francesco Gnarra ([https://github.com/francescognarra]())
|
58
|
+
|
59
|
+
## Contributing yourself
|
58
60
|
|
59
61
|
1. Fork it
|
60
62
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/email_verifier.gemspec
CHANGED
data/lib/email_verifier.rb
CHANGED
@@ -6,6 +6,15 @@ module EmailVerifier
|
|
6
6
|
require 'email_verifier/config'
|
7
7
|
require "email_verifier/validates_email_realness"
|
8
8
|
|
9
|
+
if defined?(Rails::Railtie)
|
10
|
+
class Railtie < ::Rails::Railtie #:nodoc:
|
11
|
+
initializer 'rails-i18n' do |app|
|
12
|
+
I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + '/../locales'), '*.yml')]
|
13
|
+
I18n.load_path.flatten!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
9
18
|
def self.check(email)
|
10
19
|
v = EmailVerifier::Checker.new(email)
|
11
20
|
v.connect
|
@@ -20,3 +29,4 @@ module EmailVerifier
|
|
20
29
|
end
|
21
30
|
end
|
22
31
|
end
|
32
|
+
|
@@ -28,6 +28,8 @@ class EmailVerifier::Checker
|
|
28
28
|
mxs << { priority: rr.preference, address: rr.exchange.to_s }
|
29
29
|
end
|
30
30
|
mxs.sort_by { |mx| mx[:priority] }
|
31
|
+
rescue Dnsruby::NXDomain
|
32
|
+
raise EmailVerifier::NoMailServerException.new("#{domain} does not exist")
|
31
33
|
end
|
32
34
|
|
33
35
|
def is_connected
|
@@ -7,13 +7,13 @@ module EmailVerifier
|
|
7
7
|
class EmailRealnessValidator < ActiveModel::EachValidator
|
8
8
|
def validate_each(record, attribute, value)
|
9
9
|
begin
|
10
|
-
record.errors.add attribute, '
|
10
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.email_not_real') unless EmailVerifier.check(value)
|
11
11
|
rescue EmailVerifier::OutOfMailServersException
|
12
|
-
record.errors.add attribute, '
|
12
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.out_of_mail_server')
|
13
13
|
rescue EmailVerifier::NoMailServerException
|
14
|
-
record.errors.add attribute,
|
14
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.no_mail_server')
|
15
15
|
rescue EmailVerifier::FailureException
|
16
|
-
record.errors.add attribute,
|
16
|
+
record.errors.add attribute, I18n.t('errors.messages.email_verifier.failure')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
en:
|
2
|
+
errors:
|
3
|
+
messages:
|
4
|
+
email_verifier:
|
5
|
+
email_not_real: must point at a real mail account
|
6
|
+
out_of_mail_server: appears to point at a dead mail server
|
7
|
+
no_mail_server: "appears to point at a domain which doesn't handle e-mail"
|
8
|
+
failure: could not be checked if is real
|
data/locales/pl.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
pl:
|
2
|
+
errors:
|
3
|
+
messages:
|
4
|
+
email_verifier:
|
5
|
+
email_not_real: musi wskazywać na prawdziwy adres email
|
6
|
+
out_of_mail_server: wskazuje na niedziałający serwer poczty
|
7
|
+
no_mail_server: wskazuje na domenę która nie posiada serwera pocztowego
|
8
|
+
failure: nie udało się sprawdzić prawdziwości
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_verifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -62,9 +62,11 @@ files:
|
|
62
62
|
- lib/email_verifier/exceptions.rb
|
63
63
|
- lib/email_verifier/validates_email_realness.rb
|
64
64
|
- lib/email_verifier/version.rb
|
65
|
-
-
|
65
|
+
- locales/en.yml
|
66
|
+
- locales/pl.yml
|
66
67
|
homepage: http://endpoint.com
|
67
|
-
licenses:
|
68
|
+
licenses:
|
69
|
+
- MIT
|
68
70
|
post_install_message:
|
69
71
|
rdoc_options: []
|
70
72
|
require_paths:
|
@@ -77,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
79
|
version: '0'
|
78
80
|
segments:
|
79
81
|
- 0
|
80
|
-
hash:
|
82
|
+
hash: -488036732624752134
|
81
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
84
|
none: false
|
83
85
|
requirements:
|
@@ -86,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
88
|
version: '0'
|
87
89
|
segments:
|
88
90
|
- 0
|
89
|
-
hash:
|
91
|
+
hash: -488036732624752134
|
90
92
|
requirements: []
|
91
93
|
rubyforge_project:
|
92
94
|
rubygems_version: 1.8.23
|
data/rails/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'email_verifier'
|