email_checker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Rakefile +0 -1
- data/bump +0 -0
- data/email_checker.gemspec +2 -2
- data/lib/email_checker/checker.rb +9 -12
- data/lib/email_checker/config.rb +2 -4
- data/lib/email_checker/domain.rb +2 -3
- data/lib/email_checker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6187abcb5b21a81b97d88b4f77879d237abb301
|
4
|
+
data.tar.gz: 3288b04c61442116a410264f2f36634c6b47f87c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db83aa157497c79588ad6763b7fe7589593a4ad58dd0e87578bf678cef9ac9c34ab4f678f8f09756e3ac0d8b712b25b21daa68ab7c65dd3a143495bf540dbf2b
|
7
|
+
data.tar.gz: aa6251f1b167ebb547bc43523d256b448e406d157657b422a3b82b83c1bfe0aa5a3aee2d9f39b52942af1b09d74e12ed7f92cd4adabbd1a31145c211d3a6d927
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/bump
CHANGED
File without changes
|
data/email_checker.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = EmailChecker::VERSION
|
9
9
|
spec.authors = ['Genaro Madrid']
|
10
10
|
spec.email = ['genmadrid@gmail.com']
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = 'Check if an email address is can receive E-mails.'
|
12
|
+
spec.description = "Validates, at some degree, that the email you want to send to it's valid and exists."
|
13
13
|
spec.homepage = 'https://github.com/genaromadrid/email_checker'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
@@ -23,20 +23,17 @@ module EmailChecker
|
|
23
23
|
|
24
24
|
def smtp
|
25
25
|
return @smtp if @smtp
|
26
|
-
tries ||= 5
|
27
26
|
domain.mx_servers.each do |server|
|
28
|
-
@smtp =
|
29
|
-
|
27
|
+
@smtp = connect(server[:address])
|
28
|
+
break if @smtp
|
30
29
|
end
|
31
|
-
fail EmailChecker::ServerConnectionError, "Unable to connect to any of the mail servers for #{@email}"
|
32
|
-
|
33
|
-
|
30
|
+
fail EmailChecker::ServerConnectionError, "Unable to connect to any of the mail servers for #{@email}" unless @smtp
|
31
|
+
end
|
32
|
+
|
33
|
+
def connect(address)
|
34
|
+
Net::SMTP.start(address, 25, EmailChecker.config.verifier_domain)
|
34
35
|
rescue => e
|
35
|
-
|
36
|
-
retry
|
37
|
-
else
|
38
|
-
fail EmailChecker::FailureError, e.message
|
39
|
-
end
|
36
|
+
raise EmailChecker::FailureError, e.message
|
40
37
|
end
|
41
38
|
|
42
39
|
def mailfrom
|
@@ -49,7 +46,7 @@ module EmailChecker
|
|
49
46
|
if e.message[/^550/]
|
50
47
|
return false
|
51
48
|
else
|
52
|
-
|
49
|
+
raise EmailChecker::FailureError, e.message
|
53
50
|
end
|
54
51
|
end
|
55
52
|
|
data/lib/email_checker/config.rb
CHANGED
@@ -8,9 +8,7 @@ module EmailChecker
|
|
8
8
|
def reset
|
9
9
|
@verifier_email = nil
|
10
10
|
@test_mode = false
|
11
|
-
if defined?(Rails) && defined?(Rails.env) && Rails.env.test?
|
12
|
-
@test_mode = true
|
13
|
-
end
|
11
|
+
@test_mode = true if defined?(Rails) && defined?(Rails.env) && Rails.env.test?
|
14
12
|
end
|
15
13
|
|
16
14
|
def verifier_email=(verifier_email)
|
@@ -19,6 +17,6 @@ module EmailChecker
|
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
22
|
-
|
20
|
+
reset
|
23
21
|
end
|
24
22
|
end
|
data/lib/email_checker/domain.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module EmailChecker
|
2
2
|
class Domain
|
3
|
-
|
4
3
|
def initialize(domain)
|
5
4
|
@domain = domain
|
6
5
|
end
|
@@ -10,7 +9,7 @@ module EmailChecker
|
|
10
9
|
# @return [type] [description]
|
11
10
|
def valid?
|
12
11
|
return false unless @domain
|
13
|
-
Timeout
|
12
|
+
Timeout.timeout(SERVER_TIMEOUT) do
|
14
13
|
return true if valid_mx_records?
|
15
14
|
return true if a_records?
|
16
15
|
end
|
@@ -42,7 +41,7 @@ module EmailChecker
|
|
42
41
|
end
|
43
42
|
|
44
43
|
def mx_records
|
45
|
-
@mx_records ||= dns.getresources(@domain, Resolv::DNS::Resource::IN::MX).sort_by
|
44
|
+
@mx_records ||= dns.getresources(@domain, Resolv::DNS::Resource::IN::MX).sort_by(&:preference)
|
46
45
|
end
|
47
46
|
|
48
47
|
def mx_servers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genaro Madrid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|