mail_box_validator 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mail_box_validator/mail_box.rb +8 -8
- data/lib/mail_box_validator/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: 16ef41c641a4baa65c3b37a9d7c6174273600aa9
|
4
|
+
data.tar.gz: 73ab4b28811b02a8603dca50e256b1144890de43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08fae9f324620d43bd5d4395652d37174fa25751279db7083176c4a5351493c9c6e33ef75c90ba41b6abed96d24d8d1f7473d8d384207f4fbbc7896198f5c469
|
7
|
+
data.tar.gz: bfff6e3eff7a4c9ee1ec3d741f3a6fab5b13b81b09a9af132f9bc3e09302dd27cb0182dc3794f109966882d60c2ed47d9dbedaa1db153caa9693e058a38b95c4
|
@@ -7,7 +7,13 @@ module MailBoxValidator
|
|
7
7
|
def valid?(mail_address)
|
8
8
|
domain = mail_address.slice(/@(.*)/, 1)
|
9
9
|
mx = mail_exchanger_record_for(domain)
|
10
|
-
mx.present? && mx.
|
10
|
+
mx.present? && mx.any?(&return_valid?(mail_address))
|
11
|
+
end
|
12
|
+
|
13
|
+
def mail_exchanger_record_for(domain)
|
14
|
+
Resolv::DNS.open do |dns|
|
15
|
+
dns.getresources(domain, Resolv::DNS::Resource::IN::MX).map { |r| r.exchange.to_s }
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
private
|
@@ -26,17 +32,11 @@ module MailBoxValidator
|
|
26
32
|
'Telnetmode' => true,
|
27
33
|
'Prompt' => /\d{3}.*/n
|
28
34
|
)
|
29
|
-
telnet.cmd('helo
|
35
|
+
telnet.cmd('helo #{mail_address}')
|
30
36
|
telnet.cmd("mail from: <#{mail_address}>")
|
31
37
|
telnet.cmd("rcpt to: <#{mail_address}>") { |c| response = c }
|
32
38
|
telnet.close
|
33
39
|
response
|
34
40
|
end
|
35
|
-
|
36
|
-
def mail_exchanger_record_for(domain)
|
37
|
-
Resolv::DNS.open do |dns|
|
38
|
-
dns.getresources(domain, Resolv::DNS::Resource::IN::MX).map { |r| r.exchange.to_s }
|
39
|
-
end
|
40
|
-
end
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_box_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bidu Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|