truemail 2.3.1 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +26 -3
- data/.codeclimate.yml +1 -1
- data/.reek.yml +9 -8
- data/.rubocop.yml +12 -0
- data/CHANGELOG.md +62 -3
- data/Gemfile.lock +29 -29
- data/README.md +102 -18
- data/lib/truemail/configuration.rb +19 -24
- data/lib/truemail/core.rb +5 -2
- data/lib/truemail/log/serializer/base.rb +11 -2
- data/lib/truemail/log/serializer/validator_text.rb +3 -3
- data/lib/truemail/validate/mx_blacklist.rb +26 -0
- data/lib/truemail/validate/smtp.rb +1 -1
- data/lib/truemail/validator.rb +6 -2
- data/lib/truemail/version.rb +1 -1
- data/truemail.gemspec +10 -10
- metadata +32 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90972be73db5cfcfdfe9c268d8b1ead6fc392ea2a16f230cd169600ee120a24e
|
4
|
+
data.tar.gz: c023197b5e157d53984acf19077f251e5bde284f5e9056878496495922b8ed0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eded88982cad9f59d13e3133a547e26963e9c8687ec268032b26229b8840843ed0b93fd152449cba7f376cab3d5eef592ece213e84b739b536c251cb7e28c36
|
7
|
+
data.tar.gz: dbac7df7e1414b69999fc178da524367c93d5848ba98abf08a8df8bd5ea6528d6bb416139ecd4d96e7e528d7a97d9261b538c77c8d3761e095648cea03419a21
|
data/.circleci/config.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
1
3
|
defaults: &defaults
|
2
4
|
working_directory: ~/truemail
|
3
5
|
docker:
|
@@ -5,6 +7,9 @@ defaults: &defaults
|
|
5
7
|
environment:
|
6
8
|
CC_TEST_REPORTER_ID: 693272a1328521f6f7c09d7ffd419b21c00410da26e98e94c687fdd38b26e2cb
|
7
9
|
|
10
|
+
orbs:
|
11
|
+
ruby: circleci/ruby@1.1.2
|
12
|
+
|
8
13
|
references:
|
9
14
|
restore_bundle_cache: &restore_bundle_cache
|
10
15
|
restore_cache:
|
@@ -29,7 +34,6 @@ references:
|
|
29
34
|
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
30
35
|
chmod +x ./cc-test-reporter
|
31
36
|
|
32
|
-
version: 2
|
33
37
|
jobs:
|
34
38
|
linters:
|
35
39
|
<<: *defaults
|
@@ -81,9 +85,28 @@ jobs:
|
|
81
85
|
command: |
|
82
86
|
./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
|
83
87
|
|
88
|
+
compatibility-with-ruby:
|
89
|
+
parameters:
|
90
|
+
ruby-version:
|
91
|
+
type: string
|
92
|
+
docker:
|
93
|
+
- image: cimg/ruby:<< parameters.ruby-version >>
|
94
|
+
steps:
|
95
|
+
- checkout
|
96
|
+
- ruby/install-deps:
|
97
|
+
bundler-version: '1.16.6'
|
98
|
+
with-cache: false
|
99
|
+
path: './vendor/custom_bundle'
|
100
|
+
- run:
|
101
|
+
name: Running compatibility tests
|
102
|
+
command: bundle exec rspec
|
103
|
+
|
84
104
|
workflows:
|
85
|
-
|
86
|
-
build:
|
105
|
+
build_and_test:
|
87
106
|
jobs:
|
88
107
|
- linters
|
89
108
|
- tests
|
109
|
+
- compatibility-with-ruby:
|
110
|
+
matrix:
|
111
|
+
parameters:
|
112
|
+
ruby-version: ["2.6", "2.7", "3.0"]
|
data/.codeclimate.yml
CHANGED
data/.reek.yml
CHANGED
@@ -34,18 +34,19 @@ detectors:
|
|
34
34
|
|
35
35
|
UtilityFunction:
|
36
36
|
exclude:
|
37
|
-
- Truemail::Validate::Smtp::Request#compose_from
|
38
|
-
- Truemail::Validator#select_validation_type
|
39
|
-
- Truemail::Validate::Base#configuration
|
40
|
-
- Truemail::Validate::Mx#null_mx?
|
41
|
-
- Truemail::Validate::Mx#a_record
|
42
37
|
- Truemail::Audit::Base#verifier_domain
|
43
|
-
- Truemail::Configuration#domain_matcher
|
44
38
|
- Truemail::Configuration#logger_options
|
39
|
+
- Truemail::Configuration#match_regex?
|
40
|
+
- Truemail::Configuration#regex_by_method
|
41
|
+
- Truemail::Dns::Worker#nameserver_port
|
45
42
|
- Truemail::Log::Serializer::Base#errors
|
46
43
|
- Truemail::Log::Serializer::ValidatorBase#replace_invalid_chars
|
47
|
-
- Truemail::
|
48
|
-
- Truemail::
|
44
|
+
- Truemail::Validator#select_validation_type
|
45
|
+
- Truemail::Validator#constantize
|
46
|
+
- Truemail::Validate::Base#configuration
|
47
|
+
- Truemail::Validate::Mx#null_mx?
|
48
|
+
- Truemail::Validate::Mx#a_record
|
49
|
+
- Truemail::Validate::Smtp::Request#compose_from
|
49
50
|
|
50
51
|
ControlParameter:
|
51
52
|
exclude:
|
data/.rubocop.yml
CHANGED
@@ -151,6 +151,9 @@ Style/IfWithBooleanLiteralBranches:
|
|
151
151
|
Style/HashConversion:
|
152
152
|
Enabled: true
|
153
153
|
|
154
|
+
Style/StringChars:
|
155
|
+
Enabled: true
|
156
|
+
|
154
157
|
Layout/LineLength:
|
155
158
|
Max: 140
|
156
159
|
|
@@ -347,6 +350,15 @@ Performance/ConstantRegexp:
|
|
347
350
|
Performance/MethodObjectAsBlock:
|
348
351
|
Enabled: true
|
349
352
|
|
353
|
+
Performance/RedundantEqualityComparisonBlock:
|
354
|
+
Enabled: true
|
355
|
+
|
356
|
+
Performance/RedundantSplitRegexpArgument:
|
357
|
+
Enabled: true
|
358
|
+
|
359
|
+
Performance/MapCompact:
|
360
|
+
Enabled: true
|
361
|
+
|
350
362
|
RSpec/ExampleLength:
|
351
363
|
Enabled: false
|
352
364
|
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,66 @@
|
|
2
2
|
|
3
3
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
4
4
|
|
5
|
-
## [2.
|
5
|
+
## [2.4.1] - 2021.05.05
|
6
|
+
|
7
|
+
### Updated
|
8
|
+
|
9
|
+
- `Truemail::Validate::MxBlacklist`, tests
|
10
|
+
- Updated gem development dependencies
|
11
|
+
- Updated gem documentation, version
|
12
|
+
|
13
|
+
## [2.4.0] - 2021.04.28
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- Implemented `MxBlacklist` validation. This layer provides checking mail servers with predefined blacklisted IP addresses list and can be used as a part of DEA ([disposable email address](https://en.wikipedia.org/wiki/Disposable_email_address)) validations.
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
Truemail.configure do |config|
|
21
|
+
# Optional parameter. With this option Truemail will filter out unwanted mx servers via
|
22
|
+
# predefined list of ip addresses. It can be used as a part of DEA (disposable email
|
23
|
+
# address) validations. It is equal to empty array by default.
|
24
|
+
config.blacklisted_mx_ip_addresses = ['1.1.1.1', '2.2.2.2']
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
### Changed
|
29
|
+
|
30
|
+
- Updated `Truemail::Core`, tests
|
31
|
+
- Updated `Truemail::Configuration`, tests
|
32
|
+
- Updated `Truemail::Validator`
|
33
|
+
- Updated `Truemail::Validate::Smtp`, tests
|
34
|
+
- Updated `Truemail::Log::Serializer::Base`, dependent tests
|
35
|
+
- Updated `Truemail::Log::Serializer::ValidatorText`, tests
|
36
|
+
- Updated gem development dependencies
|
37
|
+
- Updated gem documentation, changelog, version
|
38
|
+
|
39
|
+
## [2.3.4] - 2021.04.16
|
40
|
+
|
41
|
+
### Fixed
|
42
|
+
|
43
|
+
Fixed bug with impossibility to use valid dns port number. Now validation for dns port for range `1..65535` works as expected.
|
44
|
+
|
45
|
+
- Updated `Truemail::RegexConstant::REGEX_PORT_NUMBER`, tests
|
46
|
+
- Updated gem documentation
|
47
|
+
- CircleCI config moved to `.circleci/config.yml`
|
48
|
+
|
49
|
+
## [2.3.3] - 2021.04.14
|
50
|
+
|
51
|
+
### Changed
|
52
|
+
|
53
|
+
- Updated gem development dependencies
|
54
|
+
- Updated rubocop/codeclimate config
|
55
|
+
- Updated CircleCI config
|
56
|
+
|
57
|
+
## [2.3.2] - 2021.03.08
|
58
|
+
|
59
|
+
### Changed
|
60
|
+
|
61
|
+
- Updated gem development dependencies
|
62
|
+
- Updated rubocop/codeclimate config
|
63
|
+
|
64
|
+
## [2.3.1] - 2021.02.26
|
6
65
|
|
7
66
|
### Changed
|
8
67
|
|
@@ -10,7 +69,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
10
69
|
- Updated rubocop/codeclimate config
|
11
70
|
- Updated tests
|
12
71
|
|
13
|
-
## [2.3.0] -
|
72
|
+
## [2.3.0] - 2021.02.05
|
14
73
|
|
15
74
|
### Added
|
16
75
|
|
@@ -43,7 +102,7 @@ end
|
|
43
102
|
- Updated gem runtime/development dependencies
|
44
103
|
- Updated gem documentation, changelog, version
|
45
104
|
|
46
|
-
## [2.2.3] -
|
105
|
+
## [2.2.3] - 2021.01.12
|
47
106
|
|
48
107
|
### Fixed
|
49
108
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
truemail (2.
|
4
|
+
truemail (2.4.1)
|
5
5
|
simpleidn (~> 0.2.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -10,9 +10,9 @@ GEM
|
|
10
10
|
addressable (2.7.0)
|
11
11
|
public_suffix (>= 2.0.2, < 5.0)
|
12
12
|
ast (2.4.2)
|
13
|
-
bundler-audit (0.
|
13
|
+
bundler-audit (0.8.0)
|
14
14
|
bundler (>= 1.2.0, < 3)
|
15
|
-
thor (
|
15
|
+
thor (~> 1.0)
|
16
16
|
byebug (11.1.3)
|
17
17
|
childprocess (4.0.0)
|
18
18
|
coderay (1.1.3)
|
@@ -21,28 +21,28 @@ GEM
|
|
21
21
|
crack (0.4.5)
|
22
22
|
rexml
|
23
23
|
diff-lcs (1.4.4)
|
24
|
-
dns_mock (1.2.
|
24
|
+
dns_mock (1.2.1)
|
25
25
|
docile (1.3.5)
|
26
|
-
faker (2.
|
26
|
+
faker (2.17.0)
|
27
27
|
i18n (>= 1.6, < 2)
|
28
28
|
fasterer (0.9.0)
|
29
29
|
colorize (~> 0.7)
|
30
30
|
ruby_parser (>= 3.14.1)
|
31
31
|
hashdiff (1.0.1)
|
32
|
-
i18n (1.8.
|
32
|
+
i18n (1.8.10)
|
33
33
|
concurrent-ruby (~> 1.0)
|
34
34
|
iniparse (1.5.0)
|
35
35
|
json (2.5.1)
|
36
36
|
json_matchers (0.11.1)
|
37
37
|
json_schema
|
38
|
-
json_schema (0.
|
38
|
+
json_schema (0.21.0)
|
39
39
|
kwalify (0.7.2)
|
40
40
|
method_source (1.0.0)
|
41
41
|
overcommit (0.57.0)
|
42
42
|
childprocess (>= 0.6.3, < 5)
|
43
43
|
iniparse (~> 1.4)
|
44
44
|
parallel (1.20.1)
|
45
|
-
parser (3.0.
|
45
|
+
parser (3.0.1.1)
|
46
46
|
ast (~> 2.4.1)
|
47
47
|
pry (0.13.1)
|
48
48
|
coderay (~> 1.1)
|
@@ -54,13 +54,13 @@ GEM
|
|
54
54
|
public_suffix (4.0.6)
|
55
55
|
rainbow (3.0.0)
|
56
56
|
rake (13.0.3)
|
57
|
-
reek (6.0.
|
57
|
+
reek (6.0.4)
|
58
58
|
kwalify (~> 0.7.0)
|
59
59
|
parser (~> 3.0.0)
|
60
60
|
psych (~> 3.1)
|
61
61
|
rainbow (>= 2.0, < 4.0)
|
62
62
|
regexp_parser (2.1.1)
|
63
|
-
rexml (3.2.
|
63
|
+
rexml (3.2.5)
|
64
64
|
rspec (3.10.0)
|
65
65
|
rspec-core (~> 3.10.0)
|
66
66
|
rspec-expectations (~> 3.10.0)
|
@@ -74,21 +74,21 @@ GEM
|
|
74
74
|
diff-lcs (>= 1.2.0, < 2.0)
|
75
75
|
rspec-support (~> 3.10.0)
|
76
76
|
rspec-support (3.10.2)
|
77
|
-
rubocop (1.
|
77
|
+
rubocop (1.14.0)
|
78
78
|
parallel (~> 1.10)
|
79
79
|
parser (>= 3.0.0.0)
|
80
80
|
rainbow (>= 2.2.2, < 4.0)
|
81
81
|
regexp_parser (>= 1.8, < 3.0)
|
82
82
|
rexml
|
83
|
-
rubocop-ast (>= 1.
|
83
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
84
84
|
ruby-progressbar (~> 1.7)
|
85
85
|
unicode-display_width (>= 1.4.0, < 3.0)
|
86
|
-
rubocop-ast (1.
|
87
|
-
parser (>=
|
88
|
-
rubocop-performance (1.
|
89
|
-
rubocop (>=
|
86
|
+
rubocop-ast (1.5.0)
|
87
|
+
parser (>= 3.0.1.1)
|
88
|
+
rubocop-performance (1.11.2)
|
89
|
+
rubocop (>= 1.7.0, < 2.0)
|
90
90
|
rubocop-ast (>= 0.4.0)
|
91
|
-
rubocop-rspec (2.
|
91
|
+
rubocop-rspec (2.3.0)
|
92
92
|
rubocop (~> 1.0)
|
93
93
|
rubocop-ast (>= 1.1.0)
|
94
94
|
ruby-progressbar (1.11.0)
|
@@ -103,15 +103,15 @@ GEM
|
|
103
103
|
simpleidn (0.2.1)
|
104
104
|
unf (~> 0.1.4)
|
105
105
|
thor (1.1.0)
|
106
|
-
truemail-rspec (0.
|
107
|
-
faker (~> 2.
|
106
|
+
truemail-rspec (0.5.0)
|
107
|
+
faker (~> 2.17)
|
108
108
|
rspec (~> 3.10)
|
109
109
|
truemail (>= 2.3)
|
110
110
|
unf (0.1.4)
|
111
111
|
unf_ext
|
112
112
|
unf_ext (0.0.7.7)
|
113
113
|
unicode-display_width (2.0.0)
|
114
|
-
webmock (3.12.
|
114
|
+
webmock (3.12.2)
|
115
115
|
addressable (>= 2.3.6)
|
116
116
|
crack (>= 0.3.2)
|
117
117
|
hashdiff (>= 0.4.0, < 2.0.0)
|
@@ -121,23 +121,23 @@ PLATFORMS
|
|
121
121
|
|
122
122
|
DEPENDENCIES
|
123
123
|
bundler (~> 1.16)
|
124
|
-
bundler-audit (~> 0.
|
125
|
-
dns_mock (~> 1.2)
|
126
|
-
faker (~> 2.
|
124
|
+
bundler-audit (~> 0.8.0)
|
125
|
+
dns_mock (~> 1.2, >= 1.2.1)
|
126
|
+
faker (~> 2.17)
|
127
127
|
fasterer (~> 0.9.0)
|
128
128
|
json_matchers (~> 0.11.1)
|
129
129
|
overcommit (~> 0.57.0)
|
130
130
|
pry-byebug (~> 3.9)
|
131
131
|
rake (~> 13.0, >= 13.0.3)
|
132
|
-
reek (~> 6.0, >= 6.0.
|
132
|
+
reek (~> 6.0, >= 6.0.4)
|
133
133
|
rspec (~> 3.10)
|
134
|
-
rubocop (~> 1.
|
135
|
-
rubocop-performance (~> 1.
|
136
|
-
rubocop-rspec (~> 2.
|
134
|
+
rubocop (~> 1.14)
|
135
|
+
rubocop-performance (~> 1.11, >= 1.11.2)
|
136
|
+
rubocop-rspec (~> 2.3)
|
137
137
|
simplecov (~> 0.17.1)
|
138
138
|
truemail!
|
139
|
-
truemail-rspec (~> 0.
|
140
|
-
webmock (~> 3.12)
|
139
|
+
truemail-rspec (~> 0.5)
|
140
|
+
webmock (~> 3.12, >= 3.12.2)
|
141
141
|
|
142
142
|
BUNDLED WITH
|
143
143
|
1.16.6
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
[![GitHub](https://img.shields.io/github/license/truemail-rb/truemail)](LICENSE.txt)
|
11
11
|
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
|
12
12
|
|
13
|
-
Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS and
|
13
|
+
Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists.
|
14
14
|
|
15
15
|
> Actual and maintainable documentation :books: for developers is living [here](https://truemail-rb.org/truemail-gem).
|
16
16
|
|
@@ -39,6 +39,7 @@ Configurable framework agnostic plain Ruby email validator. Verify email via Reg
|
|
39
39
|
- [DNS (MX) validation](#mx-validation)
|
40
40
|
- [RFC MX lookup flow](#rfc-mx-lookup-flow)
|
41
41
|
- [Not RFC MX lookup flow](#not-rfc-mx-lookup-flow)
|
42
|
+
- [MX blacklist validation](#mx-blacklist-validation)
|
42
43
|
- [SMTP validation](#smtp-validation)
|
43
44
|
- [SMTP fail fast enabled](#smtp-fail-fast-enabled)
|
44
45
|
- [SMTP safe check disabled](#smtp-safe-check-disabled)
|
@@ -80,10 +81,11 @@ Also Truemail gem allows performing an audit of the host in which runs.
|
|
80
81
|
## Features
|
81
82
|
|
82
83
|
- Configurable validator, validate only what you need
|
83
|
-
-
|
84
|
+
- Only one runtime dependency
|
84
85
|
- Supporting of internationalized emails ([EAI](https://en.wikipedia.org/wiki/Email_address#Internationalization))
|
85
86
|
- Whitelist/blacklist validation layers
|
86
87
|
- Ability to configure different MX/SMTP validation flows
|
88
|
+
- Ability to configure [DEA](https://en.wikipedia.org/wiki/Disposable_email_address) validation flow
|
87
89
|
- Simple SMTP debugger
|
88
90
|
- Event logger
|
89
91
|
- Host auditor tools (helps to detect common host problems interfering to proper email verification)
|
@@ -132,6 +134,7 @@ You can use global gem configuration or custom independent configuration. Availa
|
|
132
134
|
- whitelisted domains
|
133
135
|
- whitelist validation
|
134
136
|
- blacklisted domains
|
137
|
+
- blacklisted mx ip-addresses
|
135
138
|
- custom DNS gateway(s)
|
136
139
|
- RFC MX lookup flow
|
137
140
|
- SMTP fail fast
|
@@ -200,12 +203,17 @@ Truemail.configure do |config|
|
|
200
203
|
# Optional parameter. Validation of email which contains blacklisted domain always will
|
201
204
|
# return false. Other validations will not processed even if it was defined in validation_type_for
|
202
205
|
# It is equal to empty array by default.
|
203
|
-
config.blacklisted_domains = ['
|
206
|
+
config.blacklisted_domains = ['somedomain3.com', 'somedomain4.com']
|
207
|
+
|
208
|
+
# Optional parameter. With this option Truemail will filter out unwanted mx servers via
|
209
|
+
# predefined list of ip addresses. It can be used as a part of DEA (disposable email
|
210
|
+
# address) validations. It is equal to empty array by default.
|
211
|
+
config.blacklisted_mx_ip_addresses = ['1.1.1.1', '2.2.2.2']
|
204
212
|
|
205
213
|
# Optional parameter. This option will provide to use custom DNS gateway when Truemail
|
206
|
-
# interacts with DNS. If you won't specify
|
207
|
-
# DNS TCP/UDP port 53. By default Truemail
|
208
|
-
# and this option is equal to empty array.
|
214
|
+
# interacts with DNS. Valid port numbers are in the range 1-65535. If you won't specify
|
215
|
+
# nameserver's ports Truemail will use default DNS TCP/UDP port 53. By default Truemail
|
216
|
+
# uses DNS gateway from system settings and this option is equal to empty array.
|
209
217
|
config.dns = ['10.0.0.1', '10.0.0.2:54']
|
210
218
|
|
211
219
|
# Optional parameter. This option will provide to use not RFC MX lookup flow.
|
@@ -245,11 +253,13 @@ Truemail.configuration
|
|
245
253
|
@smtp_error_body_pattern=/regex_pattern/,
|
246
254
|
@response_timeout=1,
|
247
255
|
@connection_attempts=3,
|
248
|
-
@
|
249
|
-
@
|
256
|
+
@default_validation_type=:mx,
|
257
|
+
@validation_type_by_domain={"somedomain.com" => :regex, "otherdomain.com" => :mx},
|
258
|
+
@whitelisted_domains=["somedomain1.com", "somedomain2.com"],
|
250
259
|
@whitelist_validation=true,
|
251
|
-
@blacklisted_domains=[],
|
252
|
-
@
|
260
|
+
@blacklisted_domains=["somedomain3.com", "somedomain4.com"],
|
261
|
+
@blacklisted_mx_ip_addresses=["1.1.1.1", "2.2.2.2"],
|
262
|
+
@dns=["10.0.0.1", "10.0.0.2:54"],
|
253
263
|
@verifier_domain="somedomain.com",
|
254
264
|
@verifier_email="verifier@example.com",
|
255
265
|
@not_rfc_mx_lookup_flow=true,
|
@@ -276,11 +286,13 @@ Truemail.configuration
|
|
276
286
|
@smtp_error_body_pattern=/regex_pattern/,
|
277
287
|
@response_timeout=4,
|
278
288
|
@connection_attempts=1,
|
279
|
-
@
|
280
|
-
@
|
289
|
+
@default_validation_type=:mx,
|
290
|
+
@validation_type_by_domain={"somedomain.com" => :regex, "otherdomain.com" => :mx},
|
291
|
+
@whitelisted_domains=["somedomain1.com", "somedomain2.com"],
|
281
292
|
@whitelist_validation=true,
|
282
|
-
@blacklisted_domains=[],
|
283
|
-
@
|
293
|
+
@blacklisted_domains=["somedomain3.com", "somedomain4.com"],
|
294
|
+
@blacklisted_mx_ip_addresses=["1.1.1.1", "2.2.2.2"],
|
295
|
+
@dns=["10.0.0.1", "10.0.0.2:54"],
|
284
296
|
@verifier_domain="somedomain.com",
|
285
297
|
@verifier_email="verifier@example.com",
|
286
298
|
@not_rfc_mx_lookup_flow=true,
|
@@ -361,6 +373,7 @@ Truemail.validate('email@white-domain.com')
|
|
361
373
|
smtp_debug=nil>,
|
362
374
|
configuration=#<Truemail::Configuration:0x00005629f801bd28
|
363
375
|
@blacklisted_domains=["black-domain.com", "somedomain.com"],
|
376
|
+
@blacklisted_mx_ip_addresses=[],
|
364
377
|
@dns=[],
|
365
378
|
@connection_attempts=2,
|
366
379
|
@connection_timeout=2,
|
@@ -409,6 +422,7 @@ Truemail.validate('email@white-domain.com', with: :regex)
|
|
409
422
|
configuration=
|
410
423
|
#<Truemail::Configuration:0x0000563f0d2605c8
|
411
424
|
@blacklisted_domains=[],
|
425
|
+
@blacklisted_mx_ip_addresses=[],
|
412
426
|
@dns=[],
|
413
427
|
@connection_attempts=2,
|
414
428
|
@connection_timeout=2,
|
@@ -443,6 +457,7 @@ Truemail.validate('email@domain.com', with: :regex)
|
|
443
457
|
configuration=
|
444
458
|
#<Truemail::Configuration:0x0000563f0cd82ab0
|
445
459
|
@blacklisted_domains=[],
|
460
|
+
@blacklisted_mx_ip_addresses=[],
|
446
461
|
@dns=[],
|
447
462
|
@connection_attempts=2,
|
448
463
|
@connection_timeout=2,
|
@@ -463,7 +478,7 @@ Truemail.validate('email@domain.com', with: :regex)
|
|
463
478
|
|
464
479
|
##### Blacklist case
|
465
480
|
|
466
|
-
When email in blacklist, validation type will be redefined too. Validation result returns
|
481
|
+
When email in blacklist, validation type will be redefined too. Validation result returns `false`.
|
467
482
|
|
468
483
|
```ruby
|
469
484
|
Truemail.validate('email@black-domain.com')
|
@@ -479,6 +494,7 @@ Truemail.validate('email@black-domain.com')
|
|
479
494
|
configuration=
|
480
495
|
#<Truemail::Configuration:0x0000563f0d36f4f0
|
481
496
|
@blacklisted_domains=[],
|
497
|
+
@blacklisted_mx_ip_addresses=[],
|
482
498
|
@dns=[],
|
483
499
|
@connection_attempts=2,
|
484
500
|
@connection_timeout=2,
|
@@ -515,6 +531,7 @@ Truemail.validate('email@somedomain.com')
|
|
515
531
|
configuration=
|
516
532
|
#<Truemail::Configuration:0x0000563f0d3f8fc0
|
517
533
|
@blacklisted_domains=[],
|
534
|
+
@blacklisted_mx_ip_addresses=[],
|
518
535
|
@dns=[],
|
519
536
|
@connection_attempts=2,
|
520
537
|
@connection_timeout=2,
|
@@ -559,7 +576,8 @@ Truemail.validate('email@example.com', with: :regex)
|
|
559
576
|
=> #<Truemail::Validator:0x000055590cc9bdb8
|
560
577
|
@result=
|
561
578
|
#<struct Truemail::Validator::Result
|
562
|
-
success=true,
|
579
|
+
success=true,
|
580
|
+
email="email@example.com",
|
563
581
|
domain=nil,
|
564
582
|
mail_servers=[],
|
565
583
|
errors={},
|
@@ -567,6 +585,7 @@ Truemail.validate('email@example.com', with: :regex)
|
|
567
585
|
configuration=
|
568
586
|
#<Truemail::Configuration:0x000055aa56a54d48
|
569
587
|
@blacklisted_domains=[],
|
588
|
+
@blacklisted_mx_ip_addresses=[],
|
570
589
|
@dns=[],
|
571
590
|
@connection_attempts=2,
|
572
591
|
@connection_timeout=2,
|
@@ -611,6 +630,7 @@ Truemail.validate('email@example.com', with: :regex)
|
|
611
630
|
configuration=
|
612
631
|
#<Truemail::Configuration:0x0000560e58d80830
|
613
632
|
@blacklisted_domains=[],
|
633
|
+
@blacklisted_mx_ip_addresses=[],
|
614
634
|
@dns=[],
|
615
635
|
@connection_attempts=2,
|
616
636
|
@connection_timeout=2,
|
@@ -666,6 +686,7 @@ Truemail.validate('email@example.com', with: :mx)
|
|
666
686
|
configuration=
|
667
687
|
#<Truemail::Configuration:0x0000559b6e44af70
|
668
688
|
@blacklisted_domains=[],
|
689
|
+
@blacklisted_mx_ip_addresses=[],
|
669
690
|
@dns=[],
|
670
691
|
@connection_attempts=2,
|
671
692
|
@connection_timeout=2,
|
@@ -712,6 +733,7 @@ Truemail.validate('email@example.com', with: :mx)
|
|
712
733
|
configuration=
|
713
734
|
#<Truemail::Configuration:0x0000559b6e44af70
|
714
735
|
@blacklisted_domains=[],
|
736
|
+
@blacklisted_mx_ip_addresses=[],
|
715
737
|
@dns=[],
|
716
738
|
@connection_attempts=2,
|
717
739
|
@connection_timeout=2,
|
@@ -730,12 +752,63 @@ Truemail.validate('email@example.com', with: :mx)
|
|
730
752
|
@validation_type=:mx>
|
731
753
|
```
|
732
754
|
|
755
|
+
#### MX blacklist validation
|
756
|
+
|
757
|
+
MX blacklist validation is the third validation level. This layer provides checking extracted mail server(s) IP address from MX validation with predefined blacklisted IP addresses list. It can be used as a part of DEA ([disposable email address](https://en.wikipedia.org/wiki/Disposable_email_address)) validations.
|
758
|
+
|
759
|
+
```code
|
760
|
+
[Whitelist/Blacklist] -> [Regex validation] -> [MX validation] -> [MX blacklist validation]
|
761
|
+
```
|
762
|
+
|
763
|
+
Example of usage:
|
764
|
+
|
765
|
+
```ruby
|
766
|
+
require 'truemail'
|
767
|
+
|
768
|
+
Truemail.configure do |config|
|
769
|
+
config.verifier_email = 'verifier@example.com'
|
770
|
+
config.blacklisted_mx_ip_addresses = ['127.0.1.2']
|
771
|
+
end
|
772
|
+
|
773
|
+
Truemail.validate('email@example.com', with: :mx_blacklist)
|
774
|
+
|
775
|
+
=> #<Truemail::Validator:0x00007fca0c8aea70
|
776
|
+
@result=
|
777
|
+
#<struct Truemail::Validator::Result
|
778
|
+
success=false,
|
779
|
+
email="email@example.com",
|
780
|
+
domain="example.com",
|
781
|
+
mail_servers=["127.0.1.1", "127.0.1.2"],
|
782
|
+
errors={:mx_blacklist=>"blacklisted mx server ip address"},
|
783
|
+
smtp_debug=nil,
|
784
|
+
configuration=
|
785
|
+
#<Truemail::Configuration:0x00007fca0c8aeb38
|
786
|
+
@blacklisted_domains=[],
|
787
|
+
@blacklisted_mx_ip_addresses=["127.0.1.2"],
|
788
|
+
@connection_attempts=2,
|
789
|
+
@connection_timeout=2,
|
790
|
+
@default_validation_type=:smtp,
|
791
|
+
@dns=[],
|
792
|
+
@email_pattern=/(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w|\-.+]*)@((?i-mx:[\p{L}0-9]+([\-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}))\z)/,
|
793
|
+
@not_rfc_mx_lookup_flow=false,
|
794
|
+
@response_timeout=2,
|
795
|
+
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
796
|
+
@smtp_fail_fast=false,
|
797
|
+
@smtp_safe_check=false,
|
798
|
+
@validation_type_by_domain={},
|
799
|
+
@verifier_domain="example.com",
|
800
|
+
@verifier_email="verifier@example.com",
|
801
|
+
@whitelist_validation=false,
|
802
|
+
@whitelisted_domains=[]>>,
|
803
|
+
@validation_type=:mx_blacklist>
|
804
|
+
```
|
805
|
+
|
733
806
|
#### SMTP validation
|
734
807
|
|
735
|
-
SMTP validation is a final,
|
808
|
+
SMTP validation is a final, fourth validation level. This type of validation tries to check real existence of email account on a current email server. This validation runs a chain of previous validations and if they're complete successfully then runs itself.
|
736
809
|
|
737
810
|
```code
|
738
|
-
[Whitelist/Blacklist] -> [Regex validation] -> [MX validation] -> [SMTP validation]
|
811
|
+
[Whitelist/Blacklist] -> [Regex validation] -> [MX validation] -> [MX blacklist validation] -> [SMTP validation]
|
739
812
|
```
|
740
813
|
|
741
814
|
If total count of MX servers is equal to one, `Truemail::Smtp` validator will use value from `Truemail.configuration.connection_attempts` as connection attempts. By default it's equal `2`.
|
@@ -787,6 +860,7 @@ Truemail.validate('email@example.com')
|
|
787
860
|
configuration=
|
788
861
|
#<Truemail::Configuration:0x00007fdc4504f5c8
|
789
862
|
@blacklisted_domains=[],
|
863
|
+
@blacklisted_mx_ip_addresses=[],
|
790
864
|
@dns=[],
|
791
865
|
@connection_attempts=2,
|
792
866
|
@connection_timeout=2,
|
@@ -831,6 +905,7 @@ Truemail.validate('email@example.com')
|
|
831
905
|
configuration=
|
832
906
|
#<Truemail::Configuration:0x00005615e87b9298
|
833
907
|
@blacklisted_domains=[],
|
908
|
+
@blacklisted_mx_ip_addresses=[],
|
834
909
|
@dns=[],
|
835
910
|
@connection_attempts=2,
|
836
911
|
@connection_timeout=2,
|
@@ -882,6 +957,7 @@ Truemail.validate('email@example.com')
|
|
882
957
|
configuration=
|
883
958
|
#<Truemail::Configuration:0x00005615e87b9298
|
884
959
|
@blacklisted_domains=[],
|
960
|
+
@blacklisted_mx_ip_addresses=[],
|
885
961
|
@dns=[],
|
886
962
|
@connection_attempts=2,
|
887
963
|
@connection_timeout=2,
|
@@ -945,6 +1021,7 @@ Truemail.validate('email@example.com')
|
|
945
1021
|
configuration=
|
946
1022
|
#<Truemail::Configuration:0x00005615e87b9298
|
947
1023
|
@blacklisted_domains=[],
|
1024
|
+
@blacklisted_mx_ip_addresses=[],
|
948
1025
|
@dns=[],
|
949
1026
|
@connection_attempts=2,
|
950
1027
|
@connection_timeout=2,
|
@@ -993,6 +1070,7 @@ Truemail.validate('email@example.com')
|
|
993
1070
|
configuration=
|
994
1071
|
#<Truemail::Configuration:0x00005615e87b9298
|
995
1072
|
@blacklisted_domains=[],
|
1073
|
+
@blacklisted_mx_ip_addresses=[],
|
996
1074
|
@dns=[],
|
997
1075
|
@connection_attempts=2,
|
998
1076
|
@connection_timeout=2,
|
@@ -1042,6 +1120,7 @@ Truemail.host_audit
|
|
1042
1120
|
configuration=
|
1043
1121
|
#<Truemail::Configuration:0x00005615e86327a8
|
1044
1122
|
@blacklisted_domains=[],
|
1123
|
+
@blacklisted_mx_ip_addresses=[],
|
1045
1124
|
@dns=[],
|
1046
1125
|
@connection_attempts=2,
|
1047
1126
|
@connection_timeout=2,
|
@@ -1070,6 +1149,7 @@ Truemail.host_audit
|
|
1070
1149
|
configuration=
|
1071
1150
|
#<Truemail::Configuration:0x00005615e86327a8
|
1072
1151
|
@blacklisted_domains=[],
|
1152
|
+
@blacklisted_mx_ip_addresses=[],
|
1073
1153
|
@dns=[],
|
1074
1154
|
@connection_attempts=2,
|
1075
1155
|
@connection_timeout=2,
|
@@ -1123,6 +1203,7 @@ Truemail::Log::Serializer::AuditorJson.call(Truemail.host_audit)
|
|
1123
1203
|
},
|
1124
1204
|
"configuration": {
|
1125
1205
|
"blacklisted_domains": null,
|
1206
|
+
"blacklisted_mx_ip_addresses": null,
|
1126
1207
|
"dns": null,
|
1127
1208
|
"email_pattern": "default gem value",
|
1128
1209
|
"not_rfc_mx_lookup_flow": false,
|
@@ -1163,6 +1244,7 @@ Truemail::Log::Serializer::ValidatorJson.call(Truemail.validate('nonexistent_ema
|
|
1163
1244
|
],
|
1164
1245
|
"configuration": {
|
1165
1246
|
"blacklisted_domains": null,
|
1247
|
+
"blacklisted_mx_ip_addresses": null,
|
1166
1248
|
"dns": null,
|
1167
1249
|
"email_pattern": "default gem value",
|
1168
1250
|
"not_rfc_mx_lookup_flow": false,
|
@@ -1205,6 +1287,7 @@ Truemail.host_audit.as_json
|
|
1205
1287
|
},
|
1206
1288
|
"configuration": {
|
1207
1289
|
"blacklisted_domains": null,
|
1290
|
+
"blacklisted_mx_ip_addresses": null,
|
1208
1291
|
"dns": null,
|
1209
1292
|
"email_pattern": "default gem value",
|
1210
1293
|
"not_rfc_mx_lookup_flow": false,
|
@@ -1242,6 +1325,7 @@ Truemail.validate('nonexistent_email@bestweb.com.ua').as_json
|
|
1242
1325
|
],
|
1243
1326
|
"configuration": {
|
1244
1327
|
"blacklisted_domains": null,
|
1328
|
+
"blacklisted_mx_ip_addresses": null,
|
1245
1329
|
"dns": null,
|
1246
1330
|
"email_pattern": "default gem value",
|
1247
1331
|
"not_rfc_mx_lookup_flow": false,
|
@@ -15,13 +15,14 @@ module Truemail
|
|
15
15
|
connection_attempts
|
16
16
|
whitelisted_domains
|
17
17
|
blacklisted_domains
|
18
|
+
blacklisted_mx_ip_addresses
|
19
|
+
dns
|
18
20
|
].freeze
|
19
21
|
|
20
22
|
attr_reader :verifier_email,
|
21
23
|
:verifier_domain,
|
22
24
|
:default_validation_type,
|
23
25
|
:validation_type_by_domain,
|
24
|
-
:dns,
|
25
26
|
:logger,
|
26
27
|
*Truemail::Configuration::SETTERS
|
27
28
|
|
@@ -55,9 +56,9 @@ module Truemail
|
|
55
56
|
validation_type_by_domain.merge!(settings)
|
56
57
|
end
|
57
58
|
|
58
|
-
def argument_consistent?(argument)
|
59
|
+
def argument_consistent?(method, argument)
|
59
60
|
case argument
|
60
|
-
when ::Array then
|
61
|
+
when ::Array then items_match_regex?(argument, regex_by_method(method))
|
61
62
|
when ::Integer then argument.positive?
|
62
63
|
when ::Regexp then true
|
63
64
|
end
|
@@ -65,16 +66,11 @@ module Truemail
|
|
65
66
|
|
66
67
|
Truemail::Configuration::SETTERS.each do |method|
|
67
68
|
define_method("#{method}=") do |argument|
|
68
|
-
raise_unless(argument, __method__, argument_consistent?(argument))
|
69
|
+
raise_unless(argument, __method__, argument_consistent?(method, argument))
|
69
70
|
instance_variable_set(:"@#{method}", argument)
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
|
-
def dns=(argument)
|
74
|
-
raise_unless(argument, __method__, argument.is_a?(::Array) && check_dns_settings(argument))
|
75
|
-
@dns = argument
|
76
|
-
end
|
77
|
-
|
78
74
|
def logger=(options)
|
79
75
|
tracking_event, stdout, log_absolute_path = logger_options(options)
|
80
76
|
valid_event = Truemail::Log::Event::TRACKING_EVENTS.key?(tracking_event)
|
@@ -104,6 +100,7 @@ module Truemail
|
|
104
100
|
whitelisted_domains: [],
|
105
101
|
whitelist_validation: false,
|
106
102
|
blacklisted_domains: [],
|
103
|
+
blacklisted_mx_ip_addresses: [],
|
107
104
|
dns: [],
|
108
105
|
not_rfc_mx_lookup_flow: false,
|
109
106
|
smtp_fail_fast: false,
|
@@ -115,25 +112,27 @@ module Truemail
|
|
115
112
|
raise Truemail::ArgumentError.new(argument_context, argument_name) unless condition
|
116
113
|
end
|
117
114
|
|
115
|
+
def match_regex?(regex_pattern, object)
|
116
|
+
regex_pattern.match?(object.to_s)
|
117
|
+
end
|
118
|
+
|
118
119
|
def validate_arguments(argument, method)
|
119
|
-
|
120
|
-
raise_unless(argument, method,
|
120
|
+
regex_pattern = Truemail::RegexConstant.const_get("regex_#{method[/\A.+_(.+)=\z/, 1]}_pattern".upcase)
|
121
|
+
raise_unless(argument, method, match_regex?(regex_pattern, argument))
|
121
122
|
end
|
122
123
|
|
123
124
|
def default_verifier_domain
|
124
125
|
self.verifier_domain ||= verifier_email[Truemail::RegexConstant::REGEX_EMAIL_PATTERN, 3]
|
125
126
|
end
|
126
127
|
|
127
|
-
def
|
128
|
-
|
128
|
+
def regex_by_method(method)
|
129
|
+
return Truemail::RegexConstant::REGEX_IP_ADDRESS_PATTERN if method.eql?(:blacklisted_mx_ip_addresses)
|
130
|
+
return Truemail::RegexConstant::REGEX_DNS_SERVER_ADDRESS_PATTERN if method.eql?(:dns)
|
131
|
+
Truemail::RegexConstant::REGEX_DOMAIN_PATTERN
|
129
132
|
end
|
130
133
|
|
131
|
-
def
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
def check_domain_list(domains)
|
136
|
-
domains.all?(&domain_matcher)
|
134
|
+
def items_match_regex?(items, regex_pattern)
|
135
|
+
items.all? { |item| match_regex?(regex_pattern, item) }
|
137
136
|
end
|
138
137
|
|
139
138
|
def check_validation_type(validation_type)
|
@@ -143,15 +142,11 @@ module Truemail
|
|
143
142
|
def validate_validation_type(settings)
|
144
143
|
raise_unless(settings, 'hash with settings', settings.is_a?(::Hash))
|
145
144
|
settings.each do |domain, validation_type|
|
146
|
-
|
145
|
+
raise_unless(domain, 'domain', match_regex?(Truemail::RegexConstant::REGEX_DOMAIN_PATTERN, domain))
|
147
146
|
check_validation_type(validation_type)
|
148
147
|
end
|
149
148
|
end
|
150
149
|
|
151
|
-
def check_dns_settings(dns_servers)
|
152
|
-
dns_servers.all? { |dns_server| Truemail::RegexConstant::REGEX_DNS_SERVER_ADDRESS_PATTERN.match?(dns_server.to_s) }
|
153
|
-
end
|
154
|
-
|
155
150
|
def logger_options(current_options)
|
156
151
|
Truemail::Configuration::DEFAULT_LOGGER_OPTIONS.merge(current_options).values
|
157
152
|
end
|
data/lib/truemail/core.rb
CHANGED
@@ -24,8 +24,10 @@ module Truemail
|
|
24
24
|
REGEX_DOMAIN_PATTERN = /(?=\A.{4,255}\z)(\A#{REGEX_DOMAIN}\z)/.freeze
|
25
25
|
REGEX_DOMAIN_FROM_EMAIL = /\A.+@(.+)\z/.freeze
|
26
26
|
REGEX_SMTP_ERROR_BODY_PATTERN = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i.freeze
|
27
|
-
|
28
|
-
|
27
|
+
REGEX_IP_ADDRESS = /((1\d|[1-9]|2[0-4])?\d|25[0-5])(\.\g<1>){3}/.freeze
|
28
|
+
REGEX_IP_ADDRESS_PATTERN = /\A#{REGEX_IP_ADDRESS}\z/.freeze
|
29
|
+
REGEX_PORT_NUMBER = /6553[0-5]|655[0-2]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3}/.freeze
|
30
|
+
REGEX_DNS_SERVER_ADDRESS_PATTERN = /\A#{REGEX_IP_ADDRESS}(:#{REGEX_PORT_NUMBER})?\z/.freeze
|
29
31
|
end
|
30
32
|
|
31
33
|
module Dns
|
@@ -46,6 +48,7 @@ module Truemail
|
|
46
48
|
require_relative '../truemail/validate/domain_list_match'
|
47
49
|
require_relative '../truemail/validate/regex'
|
48
50
|
require_relative '../truemail/validate/mx'
|
51
|
+
require_relative '../truemail/validate/mx_blacklist'
|
49
52
|
require_relative '../truemail/validate/smtp'
|
50
53
|
require_relative '../truemail/validate/smtp/response'
|
51
54
|
require_relative '../truemail/validate/smtp/request'
|
@@ -6,6 +6,14 @@ module Truemail
|
|
6
6
|
class Base
|
7
7
|
require 'json'
|
8
8
|
|
9
|
+
CONFIGURATION_ARRAY_ATTRS = %i[
|
10
|
+
validation_type_by_domain
|
11
|
+
whitelisted_domains
|
12
|
+
blacklisted_domains
|
13
|
+
blacklisted_mx_ip_addresses
|
14
|
+
dns
|
15
|
+
].freeze
|
16
|
+
CONFIGURATION_REGEX_ATTRS = %i[email_pattern smtp_error_body_pattern].freeze
|
9
17
|
DEFAULT_GEM_VALUE = 'default gem value'
|
10
18
|
|
11
19
|
def self.call(executor_instance)
|
@@ -30,7 +38,7 @@ module Truemail
|
|
30
38
|
|
31
39
|
alias warnings errors
|
32
40
|
|
33
|
-
|
41
|
+
Truemail::Log::Serializer::Base::CONFIGURATION_ARRAY_ATTRS.each do |method|
|
34
42
|
define_method(method) do
|
35
43
|
value = executor_configuration.public_send(method)
|
36
44
|
return if value.empty?
|
@@ -38,7 +46,7 @@ module Truemail
|
|
38
46
|
end
|
39
47
|
end
|
40
48
|
|
41
|
-
|
49
|
+
Truemail::Log::Serializer::Base::CONFIGURATION_REGEX_ATTRS.each do |method|
|
42
50
|
define_method(method) do
|
43
51
|
value = executor_configuration.public_send(method)
|
44
52
|
default_pattern = Truemail::RegexConstant.const_get(
|
@@ -55,6 +63,7 @@ module Truemail
|
|
55
63
|
whitelist_validation: executor_configuration.whitelist_validation,
|
56
64
|
whitelisted_domains: whitelisted_domains,
|
57
65
|
blacklisted_domains: blacklisted_domains,
|
66
|
+
blacklisted_mx_ip_addresses: blacklisted_mx_ip_addresses,
|
58
67
|
dns: dns,
|
59
68
|
not_rfc_mx_lookup_flow: executor_configuration.not_rfc_mx_lookup_flow,
|
60
69
|
smtp_fail_fast: executor_configuration.smtp_fail_fast,
|
@@ -19,9 +19,9 @@ module Truemail
|
|
19
19
|
def data_composer(enumerable_object)
|
20
20
|
enumerable_object.inject([]) do |formatted_data, (key, value)|
|
21
21
|
data =
|
22
|
-
case
|
23
|
-
when
|
24
|
-
when
|
22
|
+
case value
|
23
|
+
when ::Hash then "\n#{printer(value)}"
|
24
|
+
when ::Array then value.join(', ')
|
25
25
|
else value
|
26
26
|
end
|
27
27
|
formatted_data << "#{key.to_s.tr('_', ' ')}: #{data}".chomp << "\n"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Truemail
|
4
|
+
module Validate
|
5
|
+
class MxBlacklist < Truemail::Validate::Base
|
6
|
+
ERROR = 'blacklisted mx server ip address'
|
7
|
+
|
8
|
+
def run
|
9
|
+
return false unless Truemail::Validate::Mx.check(result)
|
10
|
+
return true if success(not_blacklisted_mail_servers?)
|
11
|
+
add_error(Truemail::Validate::MxBlacklist::ERROR)
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def blacklisted_ip?
|
18
|
+
->(mail_server) { configuration.blacklisted_mx_ip_addresses.include?(mail_server) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def not_blacklisted_mail_servers?
|
22
|
+
mail_servers.none?(&blacklisted_ip?)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -13,7 +13,7 @@ module Truemail
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def run
|
16
|
-
return false unless Truemail::Validate::
|
16
|
+
return false unless Truemail::Validate::MxBlacklist.check(result)
|
17
17
|
establish_smtp_connection
|
18
18
|
return true if success(success_response?)
|
19
19
|
result.smtp_debug = smtp_results
|
data/lib/truemail/validator.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Truemail
|
4
4
|
class Validator < Truemail::Executor
|
5
5
|
RESULT_ATTRS = %i[success email domain mail_servers errors smtp_debug configuration].freeze
|
6
|
-
VALIDATION_TYPES = %i[regex mx smtp].freeze
|
6
|
+
VALIDATION_TYPES = %i[regex mx mx_blacklist smtp].freeze
|
7
7
|
|
8
8
|
Result = ::Struct.new(*RESULT_ATTRS, keyword_init: true) do
|
9
9
|
def initialize(mail_servers: [], errors: {}, **args)
|
@@ -27,7 +27,7 @@ module Truemail
|
|
27
27
|
|
28
28
|
def run
|
29
29
|
Truemail::Validate::DomainListMatch.check(result)
|
30
|
-
result_not_changed? ? Truemail::Validate.const_get(validation_type
|
30
|
+
result_not_changed? ? Truemail::Validate.const_get(constantize(validation_type)).check(result) : update_validation_type
|
31
31
|
logger&.push(self)
|
32
32
|
self
|
33
33
|
end
|
@@ -43,6 +43,10 @@ module Truemail
|
|
43
43
|
result.configuration.validation_type_by_domain[domain] || current_validation_type
|
44
44
|
end
|
45
45
|
|
46
|
+
def constantize(symbol)
|
47
|
+
symbol.capitalize.to_s.gsub(/_[a-z]/, &:upcase).tr('_', '').to_sym
|
48
|
+
end
|
49
|
+
|
46
50
|
def update_validation_type
|
47
51
|
@validation_type = result.success ? :whitelist : :blacklist
|
48
52
|
end
|
data/lib/truemail/version.rb
CHANGED
data/truemail.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['admin@bestweb.com.ua']
|
12
12
|
|
13
13
|
spec.summary = %(truemail)
|
14
|
-
spec.description = %(Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS and
|
14
|
+
spec.description = %(Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS, SMTP and even more.)
|
15
15
|
|
16
16
|
spec.homepage = 'https://github.com/truemail-rb/truemail'
|
17
17
|
spec.license = 'MIT'
|
@@ -34,20 +34,20 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_runtime_dependency 'simpleidn', '~> 0.2.1'
|
35
35
|
|
36
36
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
37
|
-
spec.add_development_dependency 'bundler-audit', '~> 0.
|
38
|
-
spec.add_development_dependency 'dns_mock', '~> 1.2'
|
39
|
-
spec.add_development_dependency 'faker', '~> 2.
|
37
|
+
spec.add_development_dependency 'bundler-audit', '~> 0.8.0'
|
38
|
+
spec.add_development_dependency 'dns_mock', '~> 1.2', '>= 1.2.1'
|
39
|
+
spec.add_development_dependency 'faker', '~> 2.17'
|
40
40
|
spec.add_development_dependency 'fasterer', '~> 0.9.0'
|
41
41
|
spec.add_development_dependency 'json_matchers', '~> 0.11.1'
|
42
42
|
spec.add_development_dependency 'overcommit', '~> 0.57.0'
|
43
43
|
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
44
44
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.3'
|
45
|
-
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.
|
45
|
+
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.4'
|
46
46
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
47
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
48
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.
|
49
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 2.
|
47
|
+
spec.add_development_dependency 'rubocop', '~> 1.14'
|
48
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.11', '>= 1.11.2'
|
49
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.3'
|
50
50
|
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
51
|
-
spec.add_development_dependency 'truemail-rspec', '~> 0.
|
52
|
-
spec.add_development_dependency 'webmock', '~> 3.12'
|
51
|
+
spec.add_development_dependency 'truemail-rspec', '~> 0.5'
|
52
|
+
spec.add_development_dependency 'webmock', '~> 3.12', '>= 3.12.2'
|
53
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: truemail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simpleidn
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.8.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.8.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: dns_mock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +59,9 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.2'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 1.2.1
|
62
65
|
type: :development
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -66,20 +69,23 @@ dependencies:
|
|
66
69
|
- - "~>"
|
67
70
|
- !ruby/object:Gem::Version
|
68
71
|
version: '1.2'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.2.1
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: faker
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '2.
|
81
|
+
version: '2.17'
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '2.
|
88
|
+
version: '2.17'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: fasterer
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,7 +171,7 @@ dependencies:
|
|
165
171
|
version: '6.0'
|
166
172
|
- - ">="
|
167
173
|
- !ruby/object:Gem::Version
|
168
|
-
version: 6.0.
|
174
|
+
version: 6.0.4
|
169
175
|
type: :development
|
170
176
|
prerelease: false
|
171
177
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -175,7 +181,7 @@ dependencies:
|
|
175
181
|
version: '6.0'
|
176
182
|
- - ">="
|
177
183
|
- !ruby/object:Gem::Version
|
178
|
-
version: 6.0.
|
184
|
+
version: 6.0.4
|
179
185
|
- !ruby/object:Gem::Dependency
|
180
186
|
name: rspec
|
181
187
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,48 +202,48 @@ dependencies:
|
|
196
202
|
requirements:
|
197
203
|
- - "~>"
|
198
204
|
- !ruby/object:Gem::Version
|
199
|
-
version: '1.
|
205
|
+
version: '1.14'
|
200
206
|
type: :development
|
201
207
|
prerelease: false
|
202
208
|
version_requirements: !ruby/object:Gem::Requirement
|
203
209
|
requirements:
|
204
210
|
- - "~>"
|
205
211
|
- !ruby/object:Gem::Version
|
206
|
-
version: '1.
|
212
|
+
version: '1.14'
|
207
213
|
- !ruby/object:Gem::Dependency
|
208
214
|
name: rubocop-performance
|
209
215
|
requirement: !ruby/object:Gem::Requirement
|
210
216
|
requirements:
|
211
217
|
- - "~>"
|
212
218
|
- !ruby/object:Gem::Version
|
213
|
-
version: '1.
|
219
|
+
version: '1.11'
|
214
220
|
- - ">="
|
215
221
|
- !ruby/object:Gem::Version
|
216
|
-
version: 1.
|
222
|
+
version: 1.11.2
|
217
223
|
type: :development
|
218
224
|
prerelease: false
|
219
225
|
version_requirements: !ruby/object:Gem::Requirement
|
220
226
|
requirements:
|
221
227
|
- - "~>"
|
222
228
|
- !ruby/object:Gem::Version
|
223
|
-
version: '1.
|
229
|
+
version: '1.11'
|
224
230
|
- - ">="
|
225
231
|
- !ruby/object:Gem::Version
|
226
|
-
version: 1.
|
232
|
+
version: 1.11.2
|
227
233
|
- !ruby/object:Gem::Dependency
|
228
234
|
name: rubocop-rspec
|
229
235
|
requirement: !ruby/object:Gem::Requirement
|
230
236
|
requirements:
|
231
237
|
- - "~>"
|
232
238
|
- !ruby/object:Gem::Version
|
233
|
-
version: '2.
|
239
|
+
version: '2.3'
|
234
240
|
type: :development
|
235
241
|
prerelease: false
|
236
242
|
version_requirements: !ruby/object:Gem::Requirement
|
237
243
|
requirements:
|
238
244
|
- - "~>"
|
239
245
|
- !ruby/object:Gem::Version
|
240
|
-
version: '2.
|
246
|
+
version: '2.3'
|
241
247
|
- !ruby/object:Gem::Dependency
|
242
248
|
name: simplecov
|
243
249
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,14 +264,14 @@ dependencies:
|
|
258
264
|
requirements:
|
259
265
|
- - "~>"
|
260
266
|
- !ruby/object:Gem::Version
|
261
|
-
version: '0.
|
267
|
+
version: '0.5'
|
262
268
|
type: :development
|
263
269
|
prerelease: false
|
264
270
|
version_requirements: !ruby/object:Gem::Requirement
|
265
271
|
requirements:
|
266
272
|
- - "~>"
|
267
273
|
- !ruby/object:Gem::Version
|
268
|
-
version: '0.
|
274
|
+
version: '0.5'
|
269
275
|
- !ruby/object:Gem::Dependency
|
270
276
|
name: webmock
|
271
277
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,6 +279,9 @@ dependencies:
|
|
273
279
|
- - "~>"
|
274
280
|
- !ruby/object:Gem::Version
|
275
281
|
version: '3.12'
|
282
|
+
- - ">="
|
283
|
+
- !ruby/object:Gem::Version
|
284
|
+
version: 3.12.2
|
276
285
|
type: :development
|
277
286
|
prerelease: false
|
278
287
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -280,8 +289,11 @@ dependencies:
|
|
280
289
|
- - "~>"
|
281
290
|
- !ruby/object:Gem::Version
|
282
291
|
version: '3.12'
|
292
|
+
- - ">="
|
293
|
+
- !ruby/object:Gem::Version
|
294
|
+
version: 3.12.2
|
283
295
|
description: Configurable framework agnostic plain Ruby email validator. Verify email
|
284
|
-
via Regex, DNS and
|
296
|
+
via Regex, DNS, SMTP and even more.
|
285
297
|
email:
|
286
298
|
- admin@bestweb.com.ua
|
287
299
|
executables: []
|
@@ -335,6 +347,7 @@ files:
|
|
335
347
|
- lib/truemail/validate/base.rb
|
336
348
|
- lib/truemail/validate/domain_list_match.rb
|
337
349
|
- lib/truemail/validate/mx.rb
|
350
|
+
- lib/truemail/validate/mx_blacklist.rb
|
338
351
|
- lib/truemail/validate/regex.rb
|
339
352
|
- lib/truemail/validate/smtp.rb
|
340
353
|
- lib/truemail/validate/smtp/request.rb
|