truemail 1.5.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek.yml +1 -0
- data/CHANGELOG.md +214 -0
- data/Gemfile.lock +31 -50
- data/README.md +162 -16
- data/lib/truemail.rb +3 -4
- data/lib/truemail/audit/base.rb +8 -0
- data/lib/truemail/audit/dns.rb +26 -0
- data/lib/truemail/audit/ip.rb +28 -0
- data/lib/truemail/audit/ptr.rb +7 -35
- data/lib/truemail/auditor.rb +2 -2
- data/lib/truemail/configuration.rb +2 -3
- data/lib/truemail/core.rb +24 -22
- data/lib/truemail/log/serializer/base.rb +1 -0
- data/lib/truemail/validate/mx.rb +1 -0
- data/lib/truemail/validator.rb +4 -0
- data/lib/truemail/version.rb +1 -1
- data/truemail.gemspec +7 -7
- metadata +23 -27
data/Gemfile.lock
CHANGED
@@ -1,63 +1,50 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
truemail (1.
|
4
|
+
truemail (1.8.0)
|
5
5
|
simpleidn (~> 0.1.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
ast (2.4.0)
|
11
|
-
axiom-types (0.1.1)
|
12
|
-
descendants_tracker (~> 0.0.4)
|
13
|
-
ice_nine (~> 0.11.0)
|
14
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
15
11
|
bundler-audit (0.6.1)
|
16
12
|
bundler (>= 1.2.0, < 3)
|
17
13
|
thor (~> 0.18)
|
18
|
-
byebug (11.1.
|
14
|
+
byebug (11.1.3)
|
19
15
|
childprocess (3.0.0)
|
20
|
-
codeclimate-engine-rb (0.4.1)
|
21
|
-
virtus (~> 1.0)
|
22
16
|
coderay (1.1.2)
|
23
|
-
coercible (1.0.0)
|
24
|
-
descendants_tracker (~> 0.0.1)
|
25
17
|
colorize (0.8.1)
|
26
|
-
descendants_tracker (0.0.4)
|
27
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
28
18
|
diff-lcs (1.3)
|
29
19
|
docile (1.3.2)
|
30
|
-
|
31
|
-
fasterer (0.8.1)
|
20
|
+
fasterer (0.8.3)
|
32
21
|
colorize (~> 0.7)
|
33
22
|
ruby_parser (>= 3.14.1)
|
34
|
-
ffaker (2.
|
35
|
-
|
36
|
-
iniparse (1.4.4)
|
23
|
+
ffaker (2.14.0)
|
24
|
+
iniparse (1.5.0)
|
37
25
|
jaro_winkler (1.5.4)
|
38
26
|
json (2.3.0)
|
39
27
|
json_matchers (0.11.1)
|
40
28
|
json_schema
|
41
29
|
json_schema (0.20.8)
|
42
30
|
kwalify (0.7.2)
|
43
|
-
method_source (0.
|
44
|
-
overcommit (0.
|
31
|
+
method_source (1.0.0)
|
32
|
+
overcommit (0.53.0)
|
45
33
|
childprocess (>= 0.6.3, < 4)
|
46
34
|
iniparse (~> 1.4)
|
47
35
|
parallel (1.19.1)
|
48
|
-
parser (2.7.
|
36
|
+
parser (2.7.1.2)
|
49
37
|
ast (~> 2.4.0)
|
50
|
-
pry (0.
|
51
|
-
coderay (~> 1.1
|
52
|
-
method_source (~>
|
53
|
-
pry-byebug (3.
|
38
|
+
pry (0.13.1)
|
39
|
+
coderay (~> 1.1)
|
40
|
+
method_source (~> 1.0)
|
41
|
+
pry-byebug (3.9.0)
|
54
42
|
byebug (~> 11.0)
|
55
|
-
pry (~> 0.
|
43
|
+
pry (~> 0.13.0)
|
56
44
|
psych (3.1.0)
|
57
45
|
rainbow (3.0.0)
|
58
46
|
rake (13.0.1)
|
59
|
-
reek (
|
60
|
-
codeclimate-engine-rb (~> 0.4.0)
|
47
|
+
reek (6.0.0)
|
61
48
|
kwalify (~> 0.7.0)
|
62
49
|
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
63
50
|
psych (~> 3.1.0)
|
@@ -66,15 +53,15 @@ GEM
|
|
66
53
|
rspec-core (~> 3.9.0)
|
67
54
|
rspec-expectations (~> 3.9.0)
|
68
55
|
rspec-mocks (~> 3.9.0)
|
69
|
-
rspec-core (3.9.
|
70
|
-
rspec-support (~> 3.9.
|
71
|
-
rspec-expectations (3.9.
|
56
|
+
rspec-core (3.9.2)
|
57
|
+
rspec-support (~> 3.9.3)
|
58
|
+
rspec-expectations (3.9.2)
|
72
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
60
|
rspec-support (~> 3.9.0)
|
74
61
|
rspec-mocks (3.9.1)
|
75
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
63
|
rspec-support (~> 3.9.0)
|
77
|
-
rspec-support (3.9.
|
64
|
+
rspec-support (3.9.3)
|
78
65
|
rubocop (0.79.0)
|
79
66
|
jaro_winkler (~> 1.5.1)
|
80
67
|
parallel (~> 1.10)
|
@@ -84,12 +71,12 @@ GEM
|
|
84
71
|
unicode-display_width (>= 1.4.0, < 1.7)
|
85
72
|
rubocop-performance (1.5.2)
|
86
73
|
rubocop (>= 0.71.0)
|
87
|
-
rubocop-rspec (1.
|
74
|
+
rubocop-rspec (1.39.0)
|
88
75
|
rubocop (>= 0.68.1)
|
89
76
|
ruby-progressbar (1.10.1)
|
90
|
-
ruby_parser (3.14.
|
77
|
+
ruby_parser (3.14.2)
|
91
78
|
sexp_processor (~> 4.9)
|
92
|
-
sexp_processor (4.
|
79
|
+
sexp_processor (4.14.1)
|
93
80
|
simplecov (0.17.1)
|
94
81
|
docile (~> 1.1)
|
95
82
|
json (>= 1.8, < 3)
|
@@ -98,19 +85,13 @@ GEM
|
|
98
85
|
simpleidn (0.1.1)
|
99
86
|
unf (~> 0.1.4)
|
100
87
|
thor (0.20.3)
|
101
|
-
|
102
|
-
|
103
|
-
rspec (~> 3.0)
|
88
|
+
truemail-rspec (0.1.2)
|
89
|
+
rspec (~> 3.9)
|
104
90
|
truemail (~> 1.4, >= 1.4.1)
|
105
91
|
unf (0.1.4)
|
106
92
|
unf_ext
|
107
|
-
unf_ext (0.0.7.
|
93
|
+
unf_ext (0.0.7.7)
|
108
94
|
unicode-display_width (1.6.1)
|
109
|
-
virtus (1.0.5)
|
110
|
-
axiom-types (~> 0.1)
|
111
|
-
coercible (~> 1.0)
|
112
|
-
descendants_tracker (~> 0.0, >= 0.0.3)
|
113
|
-
equalizer (~> 0.0, >= 0.0.9)
|
114
95
|
|
115
96
|
PLATFORMS
|
116
97
|
ruby
|
@@ -118,20 +99,20 @@ PLATFORMS
|
|
118
99
|
DEPENDENCIES
|
119
100
|
bundler (~> 1.16)
|
120
101
|
bundler-audit (~> 0.6.1)
|
121
|
-
fasterer (~> 0.8.
|
122
|
-
ffaker (~> 2.
|
102
|
+
fasterer (~> 0.8.3)
|
103
|
+
ffaker (~> 2.14)
|
123
104
|
json_matchers (~> 0.11.1)
|
124
|
-
overcommit (~> 0.
|
125
|
-
pry-byebug (~> 3.
|
105
|
+
overcommit (~> 0.53.0)
|
106
|
+
pry-byebug (~> 3.9)
|
126
107
|
rake (~> 13.0, >= 13.0.1)
|
127
|
-
reek (~>
|
108
|
+
reek (~> 6.0)
|
128
109
|
rspec (~> 3.9)
|
129
110
|
rubocop (~> 0.79.0)
|
130
111
|
rubocop-performance (~> 1.5, >= 1.5.2)
|
131
|
-
rubocop-rspec (~> 1.
|
112
|
+
rubocop-rspec (~> 1.39)
|
132
113
|
simplecov (~> 0.17.1)
|
133
114
|
truemail!
|
134
|
-
truemail-rspec (~> 0.1.
|
115
|
+
truemail-rspec (~> 0.1.2)
|
135
116
|
|
136
117
|
BUNDLED WITH
|
137
118
|
1.16.6
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# <img src='https://repository-images.githubusercontent.com/173723932/6dffee00-e88e-11e9-94b6-c97aacc0df00' height='250' alt='Truemail - configurable framework agnostic plain Ruby email validator' />
|
2
2
|
|
3
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/657aa241399927dcd2e2/maintainability)](https://codeclimate.com/github/rubygarage/truemail/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/657aa241399927dcd2e2/test_coverage)](https://codeclimate.com/github/rubygarage/truemail/test_coverage) [![CircleCI](https://circleci.com/gh/rubygarage/truemail/tree/master.svg?style=svg)](https://circleci.com/gh/rubygarage/truemail/tree/master) [![Gem Version](https://badge.fury.io/rb/truemail.svg)](https://badge.fury.io/rb/truemail) [![Downloads](https://img.shields.io/gem/dt/truemail.svg?colorA=004d99&colorB=0073e6)](https://rubygems.org/gems/truemail) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/657aa241399927dcd2e2/maintainability)](https://codeclimate.com/github/rubygarage/truemail/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/657aa241399927dcd2e2/test_coverage)](https://codeclimate.com/github/rubygarage/truemail/test_coverage) [![CircleCI](https://circleci.com/gh/rubygarage/truemail/tree/master.svg?style=svg)](https://circleci.com/gh/rubygarage/truemail/tree/master) [![Gem Version](https://badge.fury.io/rb/truemail.svg)](https://badge.fury.io/rb/truemail) [![Downloads](https://img.shields.io/gem/dt/truemail.svg?colorA=004d99&colorB=0073e6)](https://rubygems.org/gems/truemail) [![Gitter](https://badges.gitter.im/truemail-rb/community.svg)](https://gitter.im/truemail-rb/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
|
4
4
|
|
5
5
|
Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS and SMTP. Be sure that email address valid and exists.
|
6
6
|
|
@@ -8,6 +8,7 @@ Configurable framework agnostic plain Ruby email validator. Verify email via Reg
|
|
8
8
|
|
9
9
|
- [Synopsis](#synopsis)
|
10
10
|
- [Features](#features)
|
11
|
+
- [Requirements](#requirements)
|
11
12
|
- [Installation](#installation)
|
12
13
|
- [Usage](#usage)
|
13
14
|
- [Configuration features](#configuration-features)
|
@@ -26,6 +27,8 @@ Configurable framework agnostic plain Ruby email validator. Verify email via Reg
|
|
26
27
|
- [With default regex pattern](#with-default-regex-pattern)
|
27
28
|
- [With custom regex pattern](#with-custom-regex-pattern)
|
28
29
|
- [DNS (MX) validation](#mx-validation)
|
30
|
+
- [RFC MX lookup flow](#rfc-mx-lookup-flow)
|
31
|
+
- [Not RFC MX lookup flow](#not-rfc-mx-lookup-flow)
|
29
32
|
- [SMTP validation](#smtp-validation)
|
30
33
|
- [SMTP safe check disabled](#smtp-safe-check-disabled)
|
31
34
|
- [SMTP safe check enabled](#smtp-safe-check-enabled)
|
@@ -33,9 +36,13 @@ Configurable framework agnostic plain Ruby email validator. Verify email via Reg
|
|
33
36
|
- [Available tracking events](#available-tracking-events)
|
34
37
|
- [JSON serializer](#json-serializer)
|
35
38
|
- [Host audit features](#host-audit-features)
|
39
|
+
- [IP audit](#ip-audit)
|
40
|
+
- [DNS audit](#dns-audit)
|
36
41
|
- [PTR audit](#ptr-audit)
|
42
|
+
- [Example of using](#example-of-using)
|
37
43
|
- [Truemail helpers](#truemail-helpers)
|
38
44
|
- [.valid?](#valid)
|
45
|
+
- [#as_json](#as_json)
|
39
46
|
- [Test environment](#test-environment)
|
40
47
|
- [Truemail family](#truemail-family)
|
41
48
|
- [Contributing](#contributing)
|
@@ -66,8 +73,13 @@ Also Truemail gem allows performing an audit of the host in which runs.
|
|
66
73
|
- Whitelist/blacklist validation layers
|
67
74
|
- Simple SMTP debugger
|
68
75
|
- Event logger
|
76
|
+
- Host auditor tools (helps to detect common host problems interfering to proper email verification)
|
69
77
|
- JSON serializer
|
70
78
|
|
79
|
+
## Requirements
|
80
|
+
|
81
|
+
Ruby MRI 2.5.0+
|
82
|
+
|
71
83
|
## Installation
|
72
84
|
|
73
85
|
Add this line to your application's Gemfile:
|
@@ -78,11 +90,15 @@ gem 'truemail'
|
|
78
90
|
|
79
91
|
And then execute:
|
80
92
|
|
81
|
-
|
93
|
+
```bash
|
94
|
+
bundle
|
95
|
+
```
|
82
96
|
|
83
97
|
Or install it yourself as:
|
84
98
|
|
85
|
-
|
99
|
+
```bash
|
100
|
+
gem install truemail
|
101
|
+
```
|
86
102
|
|
87
103
|
## Usage
|
88
104
|
|
@@ -167,6 +183,11 @@ Truemail.configure do |config|
|
|
167
183
|
# It is equal to empty array by default.
|
168
184
|
config.blacklisted_domains = ['somedomain1.com', 'somedomain2.com']
|
169
185
|
|
186
|
+
# Optional parameter. This option will provide to use not RFC MX lookup flow.
|
187
|
+
# It means that MX and Null MX records will be cheked on the DNS validation layer only.
|
188
|
+
# By default this option is disabled.
|
189
|
+
config.not_rfc_mx_lookup_flow = true
|
190
|
+
|
170
191
|
# Optional parameter. This option will be parse bodies of SMTP errors. It will be helpful
|
171
192
|
# if SMTP server does not return an exact answer that the email does not exist
|
172
193
|
# By default this option is disabled, available for SMTP validation only.
|
@@ -197,7 +218,8 @@ Truemail.configuration
|
|
197
218
|
@whitelist_validation=true,
|
198
219
|
@blacklisted_domains=[],
|
199
220
|
@verifier_domain="somedomain.com",
|
200
|
-
@verifier_email="verifier@example.com"
|
221
|
+
@verifier_email="verifier@example.com",
|
222
|
+
@not_rfc_mx_lookup_flow=true,
|
201
223
|
@smtp_safe_check=true,
|
202
224
|
@logger=#<Truemail::Logger:0x0000557f837450b0
|
203
225
|
@event=:all, @file="/home/app/log/truemail.log", @stdout=true>>
|
@@ -226,6 +248,7 @@ Truemail.configuration
|
|
226
248
|
@blacklisted_domains=[],
|
227
249
|
@verifier_domain="somedomain.com",
|
228
250
|
@verifier_email="verifier@example.com",
|
251
|
+
@not_rfc_mx_lookup_flow=true,
|
229
252
|
@smtp_safe_check=true,
|
230
253
|
@logger=#<Truemail::Logger:0x0000557f837450b0
|
231
254
|
@event=:all, @file="/home/app/log/truemail.log", @stdout=true>>
|
@@ -308,6 +331,7 @@ Truemail.validate('email@white-domain.com')
|
|
308
331
|
@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)/,
|
309
332
|
@response_timeout=2,
|
310
333
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
334
|
+
@not_rfc_mx_lookup_flow=false,
|
311
335
|
@smtp_safe_check=false,
|
312
336
|
@validation_type_by_domain={"somedomain.com"=>:mx},
|
313
337
|
@verifier_domain="example.com",
|
@@ -354,6 +378,7 @@ Truemail.validate('email@white-domain.com', with: :regex)
|
|
354
378
|
@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)/,
|
355
379
|
@response_timeout=2,
|
356
380
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
381
|
+
@not_rfc_mx_lookup_flow=false,
|
357
382
|
@smtp_safe_check=false,
|
358
383
|
@validation_type_by_domain={},
|
359
384
|
@verifier_domain="example.com",
|
@@ -385,6 +410,7 @@ Truemail.validate('email@domain.com', with: :regex)
|
|
385
410
|
@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)/,
|
386
411
|
@response_timeout=2,
|
387
412
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
413
|
+
@not_rfc_mx_lookup_flow=false,
|
388
414
|
@smtp_safe_check=false,
|
389
415
|
@validation_type_by_domain={},
|
390
416
|
@verifier_domain="example.com",
|
@@ -418,6 +444,7 @@ Truemail.validate('email@black-domain.com')
|
|
418
444
|
@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)/,
|
419
445
|
@response_timeout=2,
|
420
446
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
447
|
+
@not_rfc_mx_lookup_flow=false,
|
421
448
|
@smtp_safe_check=false,
|
422
449
|
@validation_type_by_domain={},
|
423
450
|
@verifier_domain="example.com",
|
@@ -451,6 +478,7 @@ Truemail.validate('email@somedomain.com')
|
|
451
478
|
@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)/,
|
452
479
|
@response_timeout=2,
|
453
480
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
481
|
+
@not_rfc_mx_lookup_flow=false,
|
454
482
|
@smtp_safe_check=false,
|
455
483
|
@validation_type_by_domain={},
|
456
484
|
@verifier_domain="example.com",
|
@@ -500,6 +528,7 @@ Truemail.validate('email@example.com', with: :regex)
|
|
500
528
|
@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)/,
|
501
529
|
@response_timeout=2,
|
502
530
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
531
|
+
@not_rfc_mx_lookup_flow=false,
|
503
532
|
@smtp_safe_check=false,
|
504
533
|
@validation_type_by_domain={},
|
505
534
|
@verifier_domain="example.com",
|
@@ -541,6 +570,7 @@ Truemail.validate('email@example.com', with: :regex)
|
|
541
570
|
@email_pattern=/regex_pattern/,
|
542
571
|
@response_timeout=2,
|
543
572
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
573
|
+
@not_rfc_mx_lookup_flow=false,
|
544
574
|
@smtp_safe_check=false,
|
545
575
|
@validation_type_by_domain={},
|
546
576
|
@verifier_domain="example.com",
|
@@ -558,7 +588,54 @@ In fact it's DNS validation because it checks not MX records only. DNS validatio
|
|
558
588
|
[Whitelist/Blacklist] -> [Regex validation] -> [MX validation]
|
559
589
|
```
|
560
590
|
|
561
|
-
Please note, Truemail MX validator not performs strict compliance of the [RFC 5321](https://tools.ietf.org/html/rfc5321#section-5) standard for best validation outcome.
|
591
|
+
Please note, Truemail MX validator [not performs](https://github.com/rubygarage/truemail/issues/26) strict compliance of the [RFC 5321](https://tools.ietf.org/html/rfc5321#section-5) standard for best validation outcome.
|
592
|
+
|
593
|
+
##### RFC MX lookup flow
|
594
|
+
|
595
|
+
[Truemail MX lookup](https://slides.com/vladislavtrotsenko/truemail#/0/9) based on RFC 5321. It consists of 3 substeps: MX, CNAME and A record resolvers. The point of each resolver is attempt to extract the mail servers from email domain. If at least one server exists that validation is successful. Iteration is processing until resolver returns true.
|
596
|
+
|
597
|
+
Example of usage:
|
598
|
+
|
599
|
+
```ruby
|
600
|
+
require 'truemail'
|
601
|
+
|
602
|
+
Truemail.configure do |config|
|
603
|
+
config.verifier_email = 'verifier@example.com'
|
604
|
+
end
|
605
|
+
|
606
|
+
Truemail.validate('email@example.com', with: :mx)
|
607
|
+
|
608
|
+
=> #<Truemail::Validator:0x000055590c9c1c50
|
609
|
+
@result=
|
610
|
+
#<struct Truemail::Validator::Result
|
611
|
+
success=true,
|
612
|
+
email="email@example.com",
|
613
|
+
domain="example.com",
|
614
|
+
mail_servers=["127.0.1.1", "127.0.1.2"],
|
615
|
+
errors={},
|
616
|
+
smtp_debug=nil>,
|
617
|
+
configuration=
|
618
|
+
#<Truemail::Configuration:0x0000559b6e44af70
|
619
|
+
@blacklisted_domains=[],
|
620
|
+
@connection_attempts=2,
|
621
|
+
@connection_timeout=2,
|
622
|
+
@default_validation_type=:smtp,
|
623
|
+
@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)/,
|
624
|
+
@response_timeout=2,
|
625
|
+
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
626
|
+
@not_rfc_mx_lookup_flow=false,
|
627
|
+
@smtp_safe_check=false,
|
628
|
+
@validation_type_by_domain={},
|
629
|
+
@verifier_domain="example.com",
|
630
|
+
@verifier_email="verifier@example.com",
|
631
|
+
@whitelist_validation=false,
|
632
|
+
@whitelisted_domains=[]>,
|
633
|
+
@validation_type=:mx>
|
634
|
+
```
|
635
|
+
|
636
|
+
##### Not RFC MX lookup flow
|
637
|
+
|
638
|
+
Also Truemail has possibility to use not RFC MX lookup flow. It means that will be used only one MX resolver on the DNS validation layer. By default this option is disabled.
|
562
639
|
|
563
640
|
Example of usage:
|
564
641
|
|
@@ -567,6 +644,7 @@ require 'truemail'
|
|
567
644
|
|
568
645
|
Truemail.configure do |config|
|
569
646
|
config.verifier_email = 'verifier@example.com'
|
647
|
+
config.not_rfc_mx_lookup_flow = true
|
570
648
|
end
|
571
649
|
|
572
650
|
Truemail.validate('email@example.com', with: :mx)
|
@@ -589,6 +667,7 @@ Truemail.validate('email@example.com', with: :mx)
|
|
589
667
|
@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)/,
|
590
668
|
@response_timeout=2,
|
591
669
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
670
|
+
@not_rfc_mx_lookup_flow=true,
|
592
671
|
@smtp_safe_check=false,
|
593
672
|
@validation_type_by_domain={},
|
594
673
|
@verifier_domain="example.com",
|
@@ -610,7 +689,7 @@ If total count of MX servers is equal to one, ```Truemail::Smtp``` validator wil
|
|
610
689
|
|
611
690
|
By default, you don't need pass with-parameter to use it. Example of usage is specified below:
|
612
691
|
|
613
|
-
|
692
|
+
##### SMTP safe check disabled
|
614
693
|
|
615
694
|
With ```smtp_safe_check = false```
|
616
695
|
|
@@ -642,6 +721,7 @@ Truemail.validate('email@example.com')
|
|
642
721
|
@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)/,
|
643
722
|
@response_timeout=2,
|
644
723
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
724
|
+
@not_rfc_mx_lookup_flow=false,
|
645
725
|
@smtp_safe_check=false,
|
646
726
|
@validation_type_by_domain={},
|
647
727
|
@verifier_domain="example.com",
|
@@ -693,6 +773,7 @@ Truemail.validate('email@example.com')
|
|
693
773
|
@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)/,
|
694
774
|
@response_timeout=2,
|
695
775
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
776
|
+
@not_rfc_mx_lookup_flow=false,
|
696
777
|
@smtp_safe_check=false,
|
697
778
|
@validation_type_by_domain={},
|
698
779
|
@verifier_domain="example.com",
|
@@ -702,8 +783,7 @@ Truemail.validate('email@example.com')
|
|
702
783
|
@validation_type=:smtp>
|
703
784
|
```
|
704
785
|
|
705
|
-
|
706
|
-
###### SMTP safe check enabled
|
786
|
+
##### SMTP safe check enabled
|
707
787
|
|
708
788
|
With ```smtp_safe_check = true```
|
709
789
|
|
@@ -757,6 +837,7 @@ Truemail.validate('email@example.com')
|
|
757
837
|
@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)/,
|
758
838
|
@response_timeout=2,
|
759
839
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
840
|
+
@not_rfc_mx_lookup_flow=false,
|
760
841
|
@smtp_safe_check=false,
|
761
842
|
@validation_type_by_domain={},
|
762
843
|
@verifier_domain="example.com",
|
@@ -805,6 +886,7 @@ Truemail.validate('email@example.com')
|
|
805
886
|
@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)/,
|
806
887
|
@response_timeout=2,
|
807
888
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
889
|
+
@not_rfc_mx_lookup_flow=false,
|
808
890
|
@smtp_safe_check=false,
|
809
891
|
@validation_type_by_domain={},
|
810
892
|
@verifier_domain="example.com",
|
@@ -863,6 +945,7 @@ Truemail::Log::Serializer::Json.call(Truemail.validate('nonexistent_email@bestwe
|
|
863
945
|
"whitelist_validation": false,
|
864
946
|
"whitelisted_domains": null,
|
865
947
|
"blacklisted_domains": null,
|
948
|
+
"not_rfc_mx_lookup_flow": false,
|
866
949
|
"smtp_safe_check": false,
|
867
950
|
"email_pattern": "default gem value",
|
868
951
|
"smtp_error_body_pattern": "default gem value"
|
@@ -872,18 +955,31 @@ Truemail::Log::Serializer::Json.call(Truemail.validate('nonexistent_email@bestwe
|
|
872
955
|
|
873
956
|
### Host audit features
|
874
957
|
|
875
|
-
Truemail gem allows performing an audit of the host in which runs.
|
958
|
+
Truemail gem allows performing an audit of the host in which runs. It will help to detect common host problems interfering to proper email verification.
|
959
|
+
|
960
|
+
#### IP audit
|
961
|
+
|
962
|
+
Checks is current Truemail host has proper internet connection and detects current host ip address.
|
963
|
+
|
964
|
+
#### DNS audit
|
965
|
+
|
966
|
+
Checks is verifier domain refer to current Truemail host IP address.
|
876
967
|
|
877
968
|
#### PTR audit
|
878
969
|
|
879
970
|
So what is a PTR record? A PTR record, or pointer record, enables someone to perform a reverse DNS lookup. This allows them to determine your domain name based on your IP address. Because generic domain names without a PTR are often associated with spammers, incoming mail servers identify email from hosts without PTR records as spam and you can't verify yours emails qualitatively.
|
880
971
|
|
972
|
+
Checks is PTR record exists for your Truemail host ip address exists and refers to current verifier domain.
|
973
|
+
|
974
|
+
#### Example of using
|
975
|
+
|
881
976
|
```ruby
|
882
977
|
Truemail.host_audit
|
883
978
|
# Everything is good
|
884
979
|
=> #<Truemail::Auditor:0x00005580df358828
|
885
980
|
@result=
|
886
981
|
#<struct Truemail::Auditor::Result
|
982
|
+
current_host_ip="127.0.0.1",
|
887
983
|
warnings={}>,
|
888
984
|
configuration=
|
889
985
|
#<Truemail::Configuration:0x00005615e86327a8
|
@@ -894,6 +990,7 @@ Truemail.host_audit
|
|
894
990
|
@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)/,
|
895
991
|
@response_timeout=2,
|
896
992
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
993
|
+
@not_rfc_mx_lookup_flow=false,
|
897
994
|
@smtp_safe_check=false,
|
898
995
|
@validation_type_by_domain={},
|
899
996
|
@verifier_domain="example.com",
|
@@ -901,12 +998,15 @@ Truemail.host_audit
|
|
901
998
|
@whitelist_validation=false,
|
902
999
|
@whitelisted_domains=[]>
|
903
1000
|
|
904
|
-
# Has
|
1001
|
+
# Has audit warnings
|
905
1002
|
=> #<Truemail::Auditor:0x00005580df358828
|
906
1003
|
@result=
|
907
1004
|
#<struct Truemail::Auditor::Result
|
908
|
-
|
909
|
-
|
1005
|
+
current_host_ip="127.0.0.1",
|
1006
|
+
warnings={
|
1007
|
+
:dns=>"a record of verifier domain not refers to current host ip address",
|
1008
|
+
:ptr=>"ptr record does not reference to current verifier domain"
|
1009
|
+
},
|
910
1010
|
configuration=
|
911
1011
|
#<Truemail::Configuration:0x00005615e86327a8
|
912
1012
|
@blacklisted_domains=[],
|
@@ -916,6 +1016,7 @@ Truemail.host_audit
|
|
916
1016
|
@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)/,
|
917
1017
|
@response_timeout=2,
|
918
1018
|
@smtp_error_body_pattern=/(?=.*550)(?=.*(user|account|customer|mailbox)).*/i,
|
1019
|
+
@not_rfc_mx_lookup_flow=false,
|
919
1020
|
@smtp_safe_check=false,
|
920
1021
|
@validation_type_by_domain={},
|
921
1022
|
@verifier_domain="example.com",
|
@@ -928,7 +1029,7 @@ Truemail.host_audit
|
|
928
1029
|
|
929
1030
|
#### .valid?
|
930
1031
|
|
931
|
-
You can use the
|
1032
|
+
You can use the `.valid?` helper for quick validation of email address. It returns a boolean:
|
932
1033
|
|
933
1034
|
```ruby
|
934
1035
|
# It is shortcut for Truemail.validate('email@example.com').result.valid?
|
@@ -936,6 +1037,46 @@ Truemail.valid?('email@example.com')
|
|
936
1037
|
=> true
|
937
1038
|
```
|
938
1039
|
|
1040
|
+
#### #as_json
|
1041
|
+
|
1042
|
+
You can use `#as_json` helper for represent `Truemail::Validator` instance as json. Under the hood it uses internal json serializer [`Truemail::Log::Serializer::Json`](#json-serializer):
|
1043
|
+
|
1044
|
+
```ruby
|
1045
|
+
Truemail.validate('nonexistent_email@bestweb.com.ua').as_json
|
1046
|
+
|
1047
|
+
=>
|
1048
|
+
# Serialized Truemail::Validator instance
|
1049
|
+
{
|
1050
|
+
"date": "2020-05-10 10:00:00 +0200",
|
1051
|
+
"email": "nonexistent_email@bestweb.com.ua",
|
1052
|
+
"validation_type": "smtp",
|
1053
|
+
"success": false,
|
1054
|
+
"errors": {
|
1055
|
+
"smtp": "smtp error"
|
1056
|
+
},
|
1057
|
+
"smtp_debug": [
|
1058
|
+
{
|
1059
|
+
"mail_host": "213.180.193.89",
|
1060
|
+
"port_opened": true,
|
1061
|
+
"connection": true,
|
1062
|
+
"errors": {
|
1063
|
+
"rcptto": "550 5.7.1 No such user!\n"
|
1064
|
+
}
|
1065
|
+
}
|
1066
|
+
],
|
1067
|
+
"configuration": {
|
1068
|
+
"validation_type_by_domain": null,
|
1069
|
+
"whitelist_validation": false,
|
1070
|
+
"whitelisted_domains": null,
|
1071
|
+
"blacklisted_domains": null,
|
1072
|
+
"not_rfc_mx_lookup_flow": false,
|
1073
|
+
"smtp_safe_check": false,
|
1074
|
+
"email_pattern": "default gem value",
|
1075
|
+
"smtp_error_body_pattern": "default gem value"
|
1076
|
+
}
|
1077
|
+
}
|
1078
|
+
```
|
1079
|
+
|
939
1080
|
### Test environment
|
940
1081
|
|
941
1082
|
You can stub out that validation for your test environment. Just add RSpec before action:
|
@@ -968,13 +1109,18 @@ end
|
|
968
1109
|
```
|
969
1110
|
|
970
1111
|
---
|
1112
|
+
|
971
1113
|
## Truemail family
|
972
1114
|
|
973
1115
|
All Truemail extensions: https://github.com/truemail-rb
|
974
1116
|
|
975
|
-
|
976
|
-
|
977
|
-
|
1117
|
+
| Name | Type | Description |
|
1118
|
+
| --- | --- | --- |
|
1119
|
+
| [truemail server](https://github.com/truemail-rb/truemail-rack) | ruby app | Lightweight rack based web API wrapper for Truemail |
|
1120
|
+
| [truemail-rack-docker](https://github.com/truemail-rb/truemail-rack-docker-image) | docker image | Lightweight rack based web API [dockerized image](https://hub.docker.com/r/truemail/truemail-rack) :whale: of Truemail server |
|
1121
|
+
| [truemail-ruby-client](https://github.com/truemail-rb/truemail-ruby-client) | ruby gem | Truemail web API client library for Ruby |
|
1122
|
+
| [truemail-crystal-client](https://github.com/truemail-rb/truemail-crystal-client) | crystal shard | Truemail web API client library for Crystal |
|
1123
|
+
| [truemail-rspec](https://github.com/truemail-rb/truemail-rspec) | ruby gem | Truemail configuration and validator RSpec helpers |
|
978
1124
|
|
979
1125
|
## Contributing
|
980
1126
|
|