truemail 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c97288083bd45ad7d2c72816ee979f166795806193a7df46a43a4a9b9e657cef
4
- data.tar.gz: 0e332a857d8639513d71c1876de23406f6ec531174d40fbd160cedc3fcc443f1
3
+ metadata.gz: 280b30990301626ac98d8017552dfb3980cdca25e0023905cf46fc47f5360f32
4
+ data.tar.gz: '009e89519a4bc12be4d2c3d2cb33a8571af146ffe0998b0559274b0cd5224d1e'
5
5
  SHA512:
6
- metadata.gz: c7ee9a4a07c04e44b8db3ab346ce190bbaf441cf7e68202cd60b3766c4fd3cf1f9003a7d4d35023a8b87d7864be4d2d8f01580ab4cd291f3e265107e9a947455
7
- data.tar.gz: c8ec35b9b9491853303a5c49c2bfdd06111ff713c710f3058178c691daa55d9b8ff75bdd47099c91b30bd2d90bdd4b5f4fd35077fd4adcb0578cdae9909066a6
6
+ metadata.gz: 15cad3cce31888d867608331a8907d4257220d0f18ddaf2d8f98c40b9f568bf410346fc69a77fc5cc8c69d340ab9fec7c6f99c25a5d6ffe6436297c3781dcd1d
7
+ data.tar.gz: 85b3f6aca2f21867b96fe6544e228aae369ed660bb3f886b4546f1fff76c99f2b8d4c1a324c4668bcf83e4b64bb91105531d0c272cec485edb56146568e8c92b
data/.codeclimate.yml CHANGED
@@ -7,7 +7,7 @@ checks:
7
7
  plugins:
8
8
  rubocop:
9
9
  enabled: true
10
- channel: rubocop-1-3
10
+ channel: rubocop-1-9
11
11
 
12
12
  reek:
13
13
  enabled: true
data/.reek.yml CHANGED
@@ -13,6 +13,7 @@ detectors:
13
13
  - Truemail::Validate::Smtp#run
14
14
  - Truemail::Validate::Mx#hosts_from_cname_records
15
15
  - Truemail::Configuration#logger=
16
+ - Truemail::Validate::Smtp::Request#initialize
16
17
 
17
18
  TooManyInstanceVariables:
18
19
  exclude:
@@ -27,6 +28,7 @@ detectors:
27
28
  exclude:
28
29
  - Truemail::Configuration#whitelist_validation
29
30
  - Truemail::Configuration#not_rfc_mx_lookup_flow
31
+ - Truemail::Configuration#smtp_fail_fast
30
32
  - Truemail::Configuration#smtp_safe_check
31
33
  - Truemail::Wrapper#attempts
32
34
 
@@ -41,6 +43,9 @@ detectors:
41
43
  - Truemail::Configuration#domain_matcher
42
44
  - Truemail::Configuration#logger_options
43
45
  - Truemail::Log::Serializer::Base#errors
46
+ - Truemail::Log::Serializer::ValidatorBase#replace_invalid_chars
47
+ - Truemail::Dns::Worker#nameserver_port
48
+ - Truemail::Configuration#check_dns_settings
44
49
 
45
50
  ControlParameter:
46
51
  exclude:
@@ -70,5 +75,10 @@ detectors:
70
75
  exclude:
71
76
  - Truemail::Configuration#logger=
72
77
 
78
+ TooManyConstants:
79
+ exclude:
80
+ - Truemail::Configuration
81
+ - Truemail::RegexConstant
82
+
73
83
  exclude_paths:
74
84
  - spec/support/helpers
data/.rubocop.yml CHANGED
@@ -136,6 +136,18 @@ Style/NilLambda:
136
136
  Style/SwapValues:
137
137
  Enabled: true
138
138
 
139
+ Style/RedundantArgument:
140
+ Enabled: true
141
+
142
+ Style/HashExcept:
143
+ Enabled: true
144
+
145
+ Style/EndlessMethod:
146
+ Enabled: true
147
+
148
+ Style/IfWithBooleanLiteralBranches:
149
+ Enabled: true
150
+
139
151
  Layout/LineLength:
140
152
  Max: 140
141
153
 
@@ -167,6 +179,9 @@ Layout/EmptyLinesAroundAttributeAccessor:
167
179
  Layout/BeginEndAlignment:
168
180
  Enabled: true
169
181
 
182
+ Layout/SpaceBeforeBrackets:
183
+ Enabled: true
184
+
170
185
  Lint/NonDeterministicRequireOrder:
171
186
  Enabled: false
172
187
 
@@ -260,6 +275,33 @@ Lint/ToEnumArguments:
260
275
  Lint/UnmodifiedReduceAccumulator:
261
276
  Enabled: true
262
277
 
278
+ Lint/UnexpectedBlockArity:
279
+ Enabled: true
280
+
281
+ Lint/AmbiguousAssignment:
282
+ Enabled: true
283
+
284
+ Lint/DeprecatedConstants:
285
+ Enabled: true
286
+
287
+ Lint/LambdaWithoutLiteralBlock:
288
+ Enabled: true
289
+
290
+ Lint/RedundantDirGlobSort:
291
+ Enabled: true
292
+
293
+ Lint/NumberedParameterAssignment:
294
+ Enabled: true
295
+
296
+ Lint/OrAssignmentToConstant:
297
+ Enabled: true
298
+
299
+ Lint/SymbolConversion:
300
+ Enabled: true
301
+
302
+ Lint/TripleQuotes:
303
+ Enabled: true
304
+
263
305
  Performance/AncestorsInclude:
264
306
  Enabled: true
265
307
 
@@ -287,6 +329,18 @@ Performance/StringInclude:
287
329
  Performance/Sum:
288
330
  Enabled: true
289
331
 
332
+ Performance/BlockGivenWithExplicitBlock:
333
+ Enabled: true
334
+
335
+ Performance/CollectionLiteralInLoop:
336
+ Enabled: true
337
+
338
+ Performance/ConstantRegexp:
339
+ Enabled: true
340
+
341
+ Performance/MethodObjectAsBlock:
342
+ Enabled: true
343
+
290
344
  RSpec/ExampleLength:
291
345
  Enabled: false
292
346
 
data/CHANGELOG.md CHANGED
@@ -2,9 +2,104 @@
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.3.0] - 2020.02.05
6
+
7
+ ### Added
8
+
9
+ - Ability to use custom DNS gateway. Thanks [@le0pard](https://github.com/le0pard) for the great idea and [@verdi8](https://github.com/verdi8) for feature [request](https://github.com/truemail-rb/truemail/issues/126).
10
+
11
+ ```ruby
12
+ Truemail.configure do |config|
13
+ # Optional parameter. This option will provide to use custom DNS gateway when Truemail interacts
14
+ # with DNS. If you won't specify nameserver's ports DNS validation layer will use default DNS
15
+ # TCP/UDP port 53. By default Truemail uses DNS gateway from system settings and this option
16
+ # is equal to empty array.
17
+ config.dns = ['10.0.0.1', '10.0.0.2:5300']
18
+ end
19
+ ```
20
+
21
+ - Added `Truemail::Dns::Resolver`
22
+ - Added `Truemail::Dns::Worker`
23
+
24
+ ### Changed
25
+
26
+ - Updated `Truemail::Configuration`, tests
27
+ - Updated `Truemail::Validate::Mx`, tests
28
+ - Updated `Truemail::Audit::Base`
29
+ - Updated `Truemail::Audit::Dns`, tests
30
+ - Updated `Truemail::Audit::Ptr`, tests
31
+ - Updated `Truemail::Log::Serializer::Base`, dependent tests
32
+ - Updated namespaces for stdlib classes
33
+ - Updated gem development dependencies
34
+ - Updated linters/codeclimate configs
35
+ - Updated gem runtime/development dependencies
36
+ - Updated gem documentation, changelog, version
37
+
38
+ ## [2.2.3] - 2020.01.12
39
+
40
+ ### Fixed
41
+
42
+ Removed needless `Timeout.timeout` block in `Truemail::Validate::Smtp::Request#check_port`, replaced `TCPSocket` to `Socket` with native timeout detection. Thanks to [@wikiti](https://github.com/wikiti) for idea, testing on production and clean PR [#127](https://github.com/truemail-rb/truemail/pull/127).
43
+
44
+ ### Changed
45
+
46
+ - Updated `Truemail::Validate::Smtp::Request`
47
+ - Updated gem development dependencies
48
+ - Updated rubocop, reek configs
49
+
50
+ ## [2.2.2] - 2020.12.30
51
+
52
+ ### Changed
53
+
54
+ - Updated gem development dependencies
55
+ - Updated rubocop config
56
+
57
+ ## [2.2.1] - 2020.12.06
58
+
59
+ ### Fixed
60
+
61
+ - Filter out ASCII-8BIT chars for serialized SMTP response errors. Fixed `Encoding::UndefinedConversionError` in `Truemail::Log::Serializer::ValidatorJson#serialize`. Thanks to [@eni9889](https://github.com/eni9889) for report
62
+ - Added missed `smtp_fail_fast` attribute to serialized validator and auditor results
63
+
64
+ ### Added
65
+
66
+ - Added `Truemail::Log::Serializer::ValidatorBase#replace_invalid_chars`
67
+
68
+ ### Changed
69
+
70
+ - Updated `Truemail::Log::Serializer::Base`
71
+ - Updated `Truemail::Log::Serializer::ValidatorBase`
72
+ - Updated gem development dependencies
73
+
74
+ ## [2.2.0] - 2020.12.01
75
+
76
+ Ability to use fail fast behaviour for SMTP validation layer. When `smtp_fail_fast = true` it means that `truemail` ends smtp validation session after first attempt on the first mx server in any fail cases (network connection/timeout error, smtp validation error). This feature helps to reduce total time of SMTP validation session up to 1 second.
77
+
78
+ ### Added
79
+
80
+ - Added `Truemail::Configuration#smtp_fail_fast`
81
+ - Added `Truemail::Validate::Smtp#smtp_fail_fast?`
82
+ - Added `Truemail::Validate::Smtp#filtered_mail_servers_by_fail_fast_scenario`
83
+
84
+ ### Changed
85
+
86
+ - Updated `Truemail::Validate::Smtp#attempts`
87
+ - Updated `Truemail::Validate::Smtp#establish_smtp_connection`
88
+ - Updated gem documentation
89
+
90
+ It's a configurable and not required option:
91
+
92
+ ```ruby
93
+ Truemail.configure do |config|
94
+ config.smtp_fail_fast = true # by default it's equal to false
95
+ end
96
+ ```
97
+
98
+ Thanks to [@wikiti](https://github.com/wikiti) for timeout reports.
99
+
5
100
  ## [2.1.0] - 2020.11.21
6
101
 
7
- Collecting only unique ip-addresses for target mail servers. This update should reduce email validation time for case when remote server have closed connection via avoiding connection attempt to server with the same ip address.
102
+ Collecting only unique ip-addresses for target mail servers. This update reduces email validation time for case when remote server have closed connection via avoiding connection attempt to server with the same ip address.
8
103
 
9
104
  ### Changed
10
105
 
data/Gemfile.lock CHANGED
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truemail (2.1.0)
5
- simpleidn (~> 0.1.1)
4
+ truemail (2.3.0)
5
+ simpleidn (~> 0.2.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.1)
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ ast (2.4.2)
11
13
  bundler-audit (0.7.0.1)
12
14
  bundler (>= 1.2.0, < 3)
13
15
  thor (>= 0.18, < 2)
@@ -15,14 +17,22 @@ GEM
15
17
  childprocess (4.0.0)
16
18
  coderay (1.1.3)
17
19
  colorize (0.8.1)
20
+ concurrent-ruby (1.1.8)
21
+ crack (0.4.5)
22
+ rexml
18
23
  diff-lcs (1.4.4)
19
- docile (1.3.2)
24
+ dns_mock (1.2.0)
25
+ docile (1.3.5)
26
+ faker (2.15.1)
27
+ i18n (>= 1.6, < 2)
20
28
  fasterer (0.8.3)
21
29
  colorize (~> 0.7)
22
30
  ruby_parser (>= 3.14.1)
23
- ffaker (2.17.0)
31
+ hashdiff (1.0.1)
32
+ i18n (1.8.8)
33
+ concurrent-ruby (~> 1.0)
24
34
  iniparse (1.5.0)
25
- json (2.3.1)
35
+ json (2.5.1)
26
36
  json_matchers (0.11.1)
27
37
  json_schema
28
38
  json_schema (0.20.9)
@@ -31,8 +41,8 @@ GEM
31
41
  overcommit (0.57.0)
32
42
  childprocess (>= 0.6.3, < 5)
33
43
  iniparse (~> 1.4)
34
- parallel (1.20.0)
35
- parser (2.7.2.0)
44
+ parallel (1.20.1)
45
+ parser (3.0.0.0)
36
46
  ast (~> 2.4.1)
37
47
  pry (0.13.1)
38
48
  coderay (~> 1.1)
@@ -40,65 +50,71 @@ GEM
40
50
  pry-byebug (3.9.0)
41
51
  byebug (~> 11.0)
42
52
  pry (~> 0.13.0)
43
- psych (3.2.0)
53
+ psych (3.3.0)
54
+ public_suffix (4.0.6)
44
55
  rainbow (3.0.0)
45
- rake (13.0.1)
46
- reek (6.0.2)
56
+ rake (13.0.3)
57
+ reek (6.0.3)
47
58
  kwalify (~> 0.7.0)
48
- parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
59
+ parser (~> 3.0.0)
49
60
  psych (~> 3.1)
50
61
  rainbow (>= 2.0, < 4.0)
51
- regexp_parser (1.8.2)
62
+ regexp_parser (2.0.3)
52
63
  rexml (3.2.4)
53
64
  rspec (3.10.0)
54
65
  rspec-core (~> 3.10.0)
55
66
  rspec-expectations (~> 3.10.0)
56
67
  rspec-mocks (~> 3.10.0)
57
- rspec-core (3.10.0)
68
+ rspec-core (3.10.1)
58
69
  rspec-support (~> 3.10.0)
59
- rspec-expectations (3.10.0)
70
+ rspec-expectations (3.10.1)
60
71
  diff-lcs (>= 1.2.0, < 2.0)
61
72
  rspec-support (~> 3.10.0)
62
- rspec-mocks (3.10.0)
73
+ rspec-mocks (3.10.2)
63
74
  diff-lcs (>= 1.2.0, < 2.0)
64
75
  rspec-support (~> 3.10.0)
65
- rspec-support (3.10.0)
66
- rubocop (1.3.0)
76
+ rspec-support (3.10.2)
77
+ rubocop (1.9.1)
67
78
  parallel (~> 1.10)
68
- parser (>= 2.7.1.5)
79
+ parser (>= 3.0.0.0)
69
80
  rainbow (>= 2.2.2, < 4.0)
70
- regexp_parser (>= 1.8)
81
+ regexp_parser (>= 1.8, < 3.0)
71
82
  rexml
72
- rubocop-ast (>= 1.1.1)
83
+ rubocop-ast (>= 1.2.0, < 2.0)
73
84
  ruby-progressbar (~> 1.7)
74
- unicode-display_width (>= 1.4.0, < 2.0)
75
- rubocop-ast (1.1.1)
85
+ unicode-display_width (>= 1.4.0, < 3.0)
86
+ rubocop-ast (1.4.1)
76
87
  parser (>= 2.7.1.5)
77
- rubocop-performance (1.8.1)
78
- rubocop (>= 0.87.0)
88
+ rubocop-performance (1.9.2)
89
+ rubocop (>= 0.90.0, < 2.0)
79
90
  rubocop-ast (>= 0.4.0)
80
- rubocop-rspec (2.0.0)
91
+ rubocop-rspec (2.2.0)
81
92
  rubocop (~> 1.0)
82
93
  rubocop-ast (>= 1.1.0)
83
- ruby-progressbar (1.10.1)
84
- ruby_parser (3.15.0)
94
+ ruby-progressbar (1.11.0)
95
+ ruby_parser (3.15.1)
85
96
  sexp_processor (~> 4.9)
86
- sexp_processor (4.15.1)
97
+ sexp_processor (4.15.2)
87
98
  simplecov (0.17.1)
88
99
  docile (~> 1.1)
89
100
  json (>= 1.8, < 3)
90
101
  simplecov-html (~> 0.10.0)
91
102
  simplecov-html (0.10.2)
92
- simpleidn (0.1.1)
103
+ simpleidn (0.2.1)
93
104
  unf (~> 0.1.4)
94
- thor (1.0.1)
95
- truemail-rspec (0.2.1)
96
- rspec (~> 3.9)
97
- truemail (~> 1.4, >= 1.4.1)
105
+ thor (1.1.0)
106
+ truemail-rspec (0.3.3)
107
+ faker (~> 2.15, >= 2.15.1)
108
+ rspec (~> 3.10)
109
+ truemail (~> 2.2)
98
110
  unf (0.1.4)
99
111
  unf_ext
100
112
  unf_ext (0.0.7.7)
101
- unicode-display_width (1.7.0)
113
+ unicode-display_width (2.0.0)
114
+ webmock (3.11.2)
115
+ addressable (>= 2.3.6)
116
+ crack (>= 0.3.2)
117
+ hashdiff (>= 0.4.0, < 2.0.0)
102
118
 
103
119
  PLATFORMS
104
120
  ruby
@@ -106,20 +122,22 @@ PLATFORMS
106
122
  DEPENDENCIES
107
123
  bundler (~> 1.16)
108
124
  bundler-audit (~> 0.7.0.1)
125
+ dns_mock (~> 1.2)
126
+ faker (~> 2.15, >= 2.15.1)
109
127
  fasterer (~> 0.8.3)
110
- ffaker (~> 2.17)
111
128
  json_matchers (~> 0.11.1)
112
129
  overcommit (~> 0.57.0)
113
130
  pry-byebug (~> 3.9)
114
- rake (~> 13.0, >= 13.0.1)
115
- reek (~> 6.0, >= 6.0.2)
131
+ rake (~> 13.0, >= 13.0.3)
132
+ reek (~> 6.0, >= 6.0.3)
116
133
  rspec (~> 3.10)
117
- rubocop (~> 1.3)
118
- rubocop-performance (~> 1.8, >= 1.8.1)
119
- rubocop-rspec (~> 2.0)
134
+ rubocop (~> 1.9, >= 1.9.1)
135
+ rubocop-performance (~> 1.9, >= 1.9.2)
136
+ rubocop-rspec (~> 2.2)
120
137
  simplecov (~> 0.17.1)
121
138
  truemail!
122
- truemail-rspec (~> 0.2.1)
139
+ truemail-rspec (~> 0.3.3)
140
+ webmock (~> 3.11, >= 3.11.2)
123
141
 
124
142
  BUNDLED WITH
125
143
  1.16.6
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019-2020 Vladislav Trotsenko
3
+ Copyright (c) 2019-2021 Vladislav Trotsenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -40,6 +40,7 @@ Configurable framework agnostic plain Ruby email validator. Verify email via Reg
40
40
  - [RFC MX lookup flow](#rfc-mx-lookup-flow)
41
41
  - [Not RFC MX lookup flow](#not-rfc-mx-lookup-flow)
42
42
  - [SMTP validation](#smtp-validation)
43
+ - [SMTP fail fast enabled](#smtp-fail-fast-enabled)
43
44
  - [SMTP safe check disabled](#smtp-safe-check-disabled)
44
45
  - [SMTP safe check enabled](#smtp-safe-check-enabled)
45
46
  - [Host audit features](#host-audit-features)
@@ -82,10 +83,12 @@ Also Truemail gem allows performing an audit of the host in which runs.
82
83
  - Minimal runtime dependencies
83
84
  - Supporting of internationalized emails ([EAI](https://en.wikipedia.org/wiki/Email_address#Internationalization))
84
85
  - Whitelist/blacklist validation layers
86
+ - Ability to configure different MX/SMTP validation flows
85
87
  - Simple SMTP debugger
86
88
  - Event logger
87
89
  - Host auditor tools (helps to detect common host problems interfering to proper email verification)
88
90
  - JSON serializers
91
+ - Ability to use the library as independent stateless microservice ([Truemail Server](https://truemail-rb.org/truemail-rack))
89
92
 
90
93
  ## Requirements
91
94
 
@@ -129,6 +132,9 @@ You can use global gem configuration or custom independent configuration. Availa
129
132
  - whitelisted domains
130
133
  - whitelist validation
131
134
  - blacklisted domains
135
+ - custom DNS gateway(s)
136
+ - RFC MX lookup flow
137
+ - SMTP fail fast
132
138
  - SMTP safe check
133
139
  - event logger
134
140
  - JSON serializer
@@ -196,11 +202,24 @@ Truemail.configure do |config|
196
202
  # It is equal to empty array by default.
197
203
  config.blacklisted_domains = ['somedomain1.com', 'somedomain2.com']
198
204
 
205
+ # Optional parameter. This option will provide to use custom DNS gateway when Truemail interacts
206
+ # with DNS. If you won't specify nameserver's ports DNS validation layer will use default DNS
207
+ # TCP/UDP port 53. By default Truemail uses DNS gateway from system settings and this option
208
+ # is equal to empty array.
209
+ config.dns = ['10.0.0.1', '10.0.0.2:54']
210
+
199
211
  # Optional parameter. This option will provide to use not RFC MX lookup flow.
200
212
  # It means that MX and Null MX records will be cheked on the DNS validation layer only.
201
213
  # By default this option is disabled.
202
214
  config.not_rfc_mx_lookup_flow = true
203
215
 
216
+ # Optional parameter. This option will provide to use smtp fail fast behaviour. When
217
+ # smtp_fail_fast = true it means that truemail ends smtp validation session after first
218
+ # attempt on the first mx server in any fail cases (network connection/timeout error,
219
+ # smtp validation error). This feature helps to reduce total time of SMTP validation
220
+ # session up to 1 second. By default this option is disabled.
221
+ config.smtp_fail_fast = true
222
+
204
223
  # Optional parameter. This option will be parse bodies of SMTP errors. It will be helpful
205
224
  # if SMTP server does not return an exact answer that the email does not exist
206
225
  # By default this option is disabled, available for SMTP validation only.
@@ -230,9 +249,11 @@ Truemail.configuration
230
249
  @whitelisted_domains=[],
231
250
  @whitelist_validation=true,
232
251
  @blacklisted_domains=[],
252
+ @dns=[],
233
253
  @verifier_domain="somedomain.com",
234
254
  @verifier_email="verifier@example.com",
235
255
  @not_rfc_mx_lookup_flow=true,
256
+ @smtp_fail_fast=true,
236
257
  @smtp_safe_check=true,
237
258
  @logger=#<Truemail::Logger:0x0000557f837450b0
238
259
  @event=:all, @file="/home/app/log/truemail.log", @stdout=true>>
@@ -259,9 +280,11 @@ Truemail.configuration
259
280
  @whitelisted_domains=[],
260
281
  @whitelist_validation=true,
261
282
  @blacklisted_domains=[],
283
+ @dns=[],
262
284
  @verifier_domain="somedomain.com",
263
285
  @verifier_email="verifier@example.com",
264
286
  @not_rfc_mx_lookup_flow=true,
287
+ @smtp_fail_fast=true,
265
288
  @smtp_safe_check=true,
266
289
  @logger=#<Truemail::Logger:0x0000557f837450b0
267
290
  @event=:all, @file="/home/app/log/truemail.log", @stdout=true>>
@@ -294,7 +317,6 @@ Truemail.host_audit('email@example.com', custom_configuration: custom_configurat
294
317
 
295
318
  Please note, you should have global or custom configuration for use Truemail gem.
296
319
 
297
-
298
320
  ### Validation features
299
321
 
300
322
  #### Whitelist/Blacklist check
@@ -339,6 +361,7 @@ Truemail.validate('email@white-domain.com')
339
361
  smtp_debug=nil>,
340
362
  configuration=#<Truemail::Configuration:0x00005629f801bd28
341
363
  @blacklisted_domains=["black-domain.com", "somedomain.com"],
364
+ @dns=[],
342
365
  @connection_attempts=2,
343
366
  @connection_timeout=2,
344
367
  @default_validation_type=:smtp,
@@ -346,6 +369,7 @@ Truemail.validate('email@white-domain.com')
346
369
  @response_timeout=2,
347
370
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
348
371
  @not_rfc_mx_lookup_flow=false,
372
+ @smtp_fail_fast=false,
349
373
  @smtp_safe_check=false,
350
374
  @validation_type_by_domain={"somedomain.com"=>:mx},
351
375
  @verifier_domain="example.com",
@@ -385,6 +409,7 @@ Truemail.validate('email@white-domain.com', with: :regex)
385
409
  configuration=
386
410
  #<Truemail::Configuration:0x0000563f0d2605c8
387
411
  @blacklisted_domains=[],
412
+ @dns=[],
388
413
  @connection_attempts=2,
389
414
  @connection_timeout=2,
390
415
  @default_validation_type=:smtp,
@@ -392,6 +417,7 @@ Truemail.validate('email@white-domain.com', with: :regex)
392
417
  @response_timeout=2,
393
418
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
394
419
  @not_rfc_mx_lookup_flow=false,
420
+ @smtp_fail_fast=false,
395
421
  @smtp_safe_check=false,
396
422
  @validation_type_by_domain={},
397
423
  @verifier_domain="example.com",
@@ -417,6 +443,7 @@ Truemail.validate('email@domain.com', with: :regex)
417
443
  configuration=
418
444
  #<Truemail::Configuration:0x0000563f0cd82ab0
419
445
  @blacklisted_domains=[],
446
+ @dns=[],
420
447
  @connection_attempts=2,
421
448
  @connection_timeout=2,
422
449
  @default_validation_type=:smtp,
@@ -424,6 +451,7 @@ Truemail.validate('email@domain.com', with: :regex)
424
451
  @response_timeout=2,
425
452
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
426
453
  @not_rfc_mx_lookup_flow=false,
454
+ @smtp_fail_fast=false,
427
455
  @smtp_safe_check=false,
428
456
  @validation_type_by_domain={},
429
457
  @verifier_domain="example.com",
@@ -451,6 +479,7 @@ Truemail.validate('email@black-domain.com')
451
479
  configuration=
452
480
  #<Truemail::Configuration:0x0000563f0d36f4f0
453
481
  @blacklisted_domains=[],
482
+ @dns=[],
454
483
  @connection_attempts=2,
455
484
  @connection_timeout=2,
456
485
  @default_validation_type=:smtp,
@@ -458,6 +487,7 @@ Truemail.validate('email@black-domain.com')
458
487
  @response_timeout=2,
459
488
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
460
489
  @not_rfc_mx_lookup_flow=false,
490
+ @smtp_fail_fast=false,
461
491
  @smtp_safe_check=false,
462
492
  @validation_type_by_domain={},
463
493
  @verifier_domain="example.com",
@@ -485,6 +515,7 @@ Truemail.validate('email@somedomain.com')
485
515
  configuration=
486
516
  #<Truemail::Configuration:0x0000563f0d3f8fc0
487
517
  @blacklisted_domains=[],
518
+ @dns=[],
488
519
  @connection_attempts=2,
489
520
  @connection_timeout=2,
490
521
  @default_validation_type=:smtp,
@@ -492,6 +523,7 @@ Truemail.validate('email@somedomain.com')
492
523
  @response_timeout=2,
493
524
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
494
525
  @not_rfc_mx_lookup_flow=false,
526
+ @smtp_fail_fast=false,
495
527
  @smtp_safe_check=false,
496
528
  @validation_type_by_domain={},
497
529
  @verifier_domain="example.com",
@@ -535,6 +567,7 @@ Truemail.validate('email@example.com', with: :regex)
535
567
  configuration=
536
568
  #<Truemail::Configuration:0x000055aa56a54d48
537
569
  @blacklisted_domains=[],
570
+ @dns=[],
538
571
  @connection_attempts=2,
539
572
  @connection_timeout=2,
540
573
  @default_validation_type=:smtp,
@@ -542,6 +575,7 @@ Truemail.validate('email@example.com', with: :regex)
542
575
  @response_timeout=2,
543
576
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
544
577
  @not_rfc_mx_lookup_flow=false,
578
+ @smtp_fail_fast=false,
545
579
  @smtp_safe_check=false,
546
580
  @validation_type_by_domain={},
547
581
  @verifier_domain="example.com",
@@ -577,6 +611,7 @@ Truemail.validate('email@example.com', with: :regex)
577
611
  configuration=
578
612
  #<Truemail::Configuration:0x0000560e58d80830
579
613
  @blacklisted_domains=[],
614
+ @dns=[],
580
615
  @connection_attempts=2,
581
616
  @connection_timeout=2,
582
617
  @default_validation_type=:smtp,
@@ -584,6 +619,7 @@ Truemail.validate('email@example.com', with: :regex)
584
619
  @response_timeout=2,
585
620
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
586
621
  @not_rfc_mx_lookup_flow=false,
622
+ @smtp_fail_fast=false,
587
623
  @smtp_safe_check=false,
588
624
  @validation_type_by_domain={},
589
625
  @verifier_domain="example.com",
@@ -630,6 +666,7 @@ Truemail.validate('email@example.com', with: :mx)
630
666
  configuration=
631
667
  #<Truemail::Configuration:0x0000559b6e44af70
632
668
  @blacklisted_domains=[],
669
+ @dns=[],
633
670
  @connection_attempts=2,
634
671
  @connection_timeout=2,
635
672
  @default_validation_type=:smtp,
@@ -637,6 +674,7 @@ Truemail.validate('email@example.com', with: :mx)
637
674
  @response_timeout=2,
638
675
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
639
676
  @not_rfc_mx_lookup_flow=false,
677
+ @smtp_fail_fast=false,
640
678
  @smtp_safe_check=false,
641
679
  @validation_type_by_domain={},
642
680
  @verifier_domain="example.com",
@@ -674,6 +712,7 @@ Truemail.validate('email@example.com', with: :mx)
674
712
  configuration=
675
713
  #<Truemail::Configuration:0x0000559b6e44af70
676
714
  @blacklisted_domains=[],
715
+ @dns=[],
677
716
  @connection_attempts=2,
678
717
  @connection_timeout=2,
679
718
  @default_validation_type=:smtp,
@@ -681,6 +720,7 @@ Truemail.validate('email@example.com', with: :mx)
681
720
  @response_timeout=2,
682
721
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
683
722
  @not_rfc_mx_lookup_flow=true,
723
+ @smtp_fail_fast=false,
684
724
  @smtp_safe_check=false,
685
725
  @validation_type_by_domain={},
686
726
  @verifier_domain="example.com",
@@ -702,6 +742,69 @@ If total count of MX servers is equal to one, `Truemail::Smtp` validator will us
702
742
 
703
743
  By default, you don't need pass with-parameter to use it. Example of usage is specified below:
704
744
 
745
+ ##### SMTP fail fast enabled
746
+
747
+ Truemail can use fail fast behaviour for SMTP validation layer. When `smtp_fail_fast = true` it means that `truemail` ends smtp validation session after first attempt on the first mx server in any fail cases (network connection/timeout error, smtp validation error). This feature helps to reduce total time of SMTP validation session up to 1 second.
748
+
749
+ ```ruby
750
+ require 'truemail'
751
+
752
+ Truemail.configure do |config|
753
+ config.verifier_email = 'verifier@example.com'
754
+ config.smtp_fail_fast = true
755
+ end
756
+
757
+ Truemail.validate('email@example.com')
758
+
759
+ # SMTP validation failed, smtp fail fast validation scenario
760
+ => #<Truemail::Validator:0x00007fdc4504f460
761
+ @result=
762
+ #<struct Truemail::Validator::Result
763
+ success=false,
764
+ email="email@example.com",
765
+ domain="example.com",
766
+ mail_servers=["127.0.1.1", "127.0.1.2", "127.0.1.3"], # there are 3 mail servers in a row
767
+ errors={:smtp=>"smtp error"},
768
+ smtp_debug=
769
+ [#<Truemail::Validate::Smtp::Request:0x00007fdc43150b90 # but iteration has been stopped after the first failure
770
+ @attempts=nil,
771
+ @configuration=
772
+ #<Truemail::Validate::Smtp::Request::Configuration:0x00007fdc43150b18
773
+ @connection_timeout=2,
774
+ @response_timeout=2,
775
+ @verifier_domain="example.com",
776
+ @verifier_email="verifier@example.com">,
777
+ @email="email@example.com",
778
+ @host="127.0.1.1",
779
+ @response=
780
+ #<struct Truemail::Validate::Smtp::Response
781
+ port_opened=false,
782
+ connection=nil,
783
+ helo=nil,
784
+ mailfrom=nil,
785
+ rcptto=nil,
786
+ errors={}>>],
787
+ configuration=
788
+ #<Truemail::Configuration:0x00007fdc4504f5c8
789
+ @blacklisted_domains=[],
790
+ @dns=[],
791
+ @connection_attempts=2,
792
+ @connection_timeout=2,
793
+ @default_validation_type=:smtp,
794
+ @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)/,
795
+ @not_rfc_mx_lookup_flow=false,
796
+ @response_timeout=2,
797
+ @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
798
+ @smtp_fail_fast=true,
799
+ @smtp_safe_check=false,
800
+ @validation_type_by_domain={},
801
+ @verifier_domain="example.com",
802
+ @verifier_email="verifier@example.com",
803
+ @whitelist_validation=false,
804
+ @whitelisted_domains=[]>>,
805
+ @validation_type=:smtp>
806
+ ```
807
+
705
808
  ##### SMTP safe check disabled
706
809
 
707
810
  With `smtp_safe_check = false`
@@ -728,6 +831,7 @@ Truemail.validate('email@example.com')
728
831
  configuration=
729
832
  #<Truemail::Configuration:0x00005615e87b9298
730
833
  @blacklisted_domains=[],
834
+ @dns=[],
731
835
  @connection_attempts=2,
732
836
  @connection_timeout=2,
733
837
  @default_validation_type=:smtp,
@@ -735,6 +839,7 @@ Truemail.validate('email@example.com')
735
839
  @response_timeout=2,
736
840
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
737
841
  @not_rfc_mx_lookup_flow=false,
842
+ @smtp_fail_fast=false,
738
843
  @smtp_safe_check=false,
739
844
  @validation_type_by_domain={},
740
845
  @verifier_domain="example.com",
@@ -777,6 +882,7 @@ Truemail.validate('email@example.com')
777
882
  configuration=
778
883
  #<Truemail::Configuration:0x00005615e87b9298
779
884
  @blacklisted_domains=[],
885
+ @dns=[],
780
886
  @connection_attempts=2,
781
887
  @connection_timeout=2,
782
888
  @default_validation_type=:smtp,
@@ -784,6 +890,7 @@ Truemail.validate('email@example.com')
784
890
  @response_timeout=2,
785
891
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
786
892
  @not_rfc_mx_lookup_flow=false,
893
+ @smtp_fail_fast=false,
787
894
  @smtp_safe_check=false,
788
895
  @validation_type_by_domain={},
789
896
  @verifier_domain="example.com",
@@ -838,6 +945,7 @@ Truemail.validate('email@example.com')
838
945
  configuration=
839
946
  #<Truemail::Configuration:0x00005615e87b9298
840
947
  @blacklisted_domains=[],
948
+ @dns=[],
841
949
  @connection_attempts=2,
842
950
  @connection_timeout=2,
843
951
  @default_validation_type=:smtp,
@@ -845,6 +953,7 @@ Truemail.validate('email@example.com')
845
953
  @response_timeout=2,
846
954
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
847
955
  @not_rfc_mx_lookup_flow=false,
956
+ @smtp_fail_fast=false,
848
957
  @smtp_safe_check=false,
849
958
  @validation_type_by_domain={},
850
959
  @verifier_domain="example.com",
@@ -884,6 +993,7 @@ Truemail.validate('email@example.com')
884
993
  configuration=
885
994
  #<Truemail::Configuration:0x00005615e87b9298
886
995
  @blacklisted_domains=[],
996
+ @dns=[],
887
997
  @connection_attempts=2,
888
998
  @connection_timeout=2,
889
999
  @default_validation_type=:smtp,
@@ -891,6 +1001,7 @@ Truemail.validate('email@example.com')
891
1001
  @response_timeout=2,
892
1002
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
893
1003
  @not_rfc_mx_lookup_flow=false,
1004
+ @smtp_fail_fast=false,
894
1005
  @smtp_safe_check=false,
895
1006
  @validation_type_by_domain={},
896
1007
  @verifier_domain="example.com",
@@ -931,6 +1042,7 @@ Truemail.host_audit
931
1042
  configuration=
932
1043
  #<Truemail::Configuration:0x00005615e86327a8
933
1044
  @blacklisted_domains=[],
1045
+ @dns=[],
934
1046
  @connection_attempts=2,
935
1047
  @connection_timeout=2,
936
1048
  @default_validation_type=:smtp,
@@ -938,6 +1050,7 @@ Truemail.host_audit
938
1050
  @response_timeout=2,
939
1051
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
940
1052
  @not_rfc_mx_lookup_flow=false,
1053
+ @smtp_fail_fast=false,
941
1054
  @smtp_safe_check=false,
942
1055
  @validation_type_by_domain={},
943
1056
  @verifier_domain="example.com",
@@ -957,6 +1070,7 @@ Truemail.host_audit
957
1070
  configuration=
958
1071
  #<Truemail::Configuration:0x00005615e86327a8
959
1072
  @blacklisted_domains=[],
1073
+ @dns=[],
960
1074
  @connection_attempts=2,
961
1075
  @connection_timeout=2,
962
1076
  @default_validation_type=:smtp,
@@ -964,6 +1078,7 @@ Truemail.host_audit
964
1078
  @response_timeout=2,
965
1079
  @smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
966
1080
  @not_rfc_mx_lookup_flow=false,
1081
+ @smtp_fail_fast=false,
967
1082
  @smtp_safe_check=false,
968
1083
  @validation_type_by_domain={},
969
1084
  @verifier_domain="example.com",
@@ -1011,7 +1126,9 @@ Truemail::Log::Serializer::AuditorJson.call(Truemail.host_audit)
1011
1126
  "whitelist_validation": false,
1012
1127
  "whitelisted_domains": null,
1013
1128
  "blacklisted_domains": null,
1129
+ "dns": null,
1014
1130
  "not_rfc_mx_lookup_flow": false,
1131
+ "smtp_fail_fast": false,
1015
1132
  "smtp_safe_check": false,
1016
1133
  "email_pattern": "default gem value",
1017
1134
  "smtp_error_body_pattern": "default gem value"
@@ -1049,7 +1166,9 @@ Truemail::Log::Serializer::ValidatorJson.call(Truemail.validate('nonexistent_ema
1049
1166
  "whitelist_validation": false,
1050
1167
  "whitelisted_domains": null,
1051
1168
  "blacklisted_domains": null,
1169
+ "dns": null,
1052
1170
  "not_rfc_mx_lookup_flow": false,
1171
+ "smtp_fail_fast": false,
1053
1172
  "smtp_safe_check": false,
1054
1173
  "email_pattern": "default gem value",
1055
1174
  "smtp_error_body_pattern": "default gem value"
@@ -1089,7 +1208,9 @@ Truemail.host_audit.as_json
1089
1208
  "whitelist_validation": false,
1090
1209
  "whitelisted_domains": null,
1091
1210
  "blacklisted_domains": null,
1211
+ "dns": null,
1092
1212
  "not_rfc_mx_lookup_flow": false,
1213
+ "smtp_fail_fast": false,
1093
1214
  "smtp_safe_check": false,
1094
1215
  "email_pattern": "default gem value",
1095
1216
  "smtp_error_body_pattern": "default gem value"
@@ -1124,7 +1245,9 @@ Truemail.validate('nonexistent_email@bestweb.com.ua').as_json
1124
1245
  "whitelist_validation": false,
1125
1246
  "whitelisted_domains": null,
1126
1247
  "blacklisted_domains": null,
1248
+ "dns": null,
1127
1249
  "not_rfc_mx_lookup_flow": false,
1250
+ "smtp_fail_fast": false,
1128
1251
  "smtp_safe_check": false,
1129
1252
  "email_pattern": "default gem value",
1130
1253
  "smtp_error_body_pattern": "default gem value"