truemail 1.8.0 → 2.0.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 +1 -1
- data/.codeclimate.yml +1 -1
- data/.github/ISSUE_TEMPLATE.md +3 -3
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- data/.reek.yml +4 -0
- data/.rubocop.yml +186 -6
- data/CHANGELOG.md +118 -31
- data/Gemfile.lock +47 -41
- data/LICENSE.txt +1 -1
- data/README.md +143 -103
- data/lib/truemail.rb +9 -2
- data/lib/truemail/audit/dns.rb +1 -1
- data/lib/truemail/audit/ptr.rb +2 -2
- data/lib/truemail/auditor.rb +5 -3
- data/lib/truemail/configuration.rb +8 -2
- data/lib/truemail/core.rb +8 -4
- data/lib/truemail/executor.rb +11 -0
- data/lib/truemail/log/serializer/auditor_json.rb +25 -0
- data/lib/truemail/log/serializer/base.rb +17 -42
- data/lib/truemail/log/serializer/validator_base.rb +45 -0
- data/lib/truemail/log/serializer/{json.rb → validator_json.rb} +1 -1
- data/lib/truemail/log/serializer/{text.rb → validator_text.rb} +2 -2
- data/lib/truemail/logger.rb +1 -1
- data/lib/truemail/validate/smtp/request.rb +2 -3
- data/lib/truemail/validator.rb +4 -4
- data/lib/truemail/version.rb +1 -1
- data/truemail.gemspec +17 -9
- metadata +42 -22
data/Gemfile.lock
CHANGED
@@ -1,59 +1,60 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
truemail (
|
4
|
+
truemail (2.0.1)
|
5
5
|
simpleidn (~> 0.1.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
ast (2.4.
|
11
|
-
bundler-audit (0.
|
10
|
+
ast (2.4.1)
|
11
|
+
bundler-audit (0.7.0.1)
|
12
12
|
bundler (>= 1.2.0, < 3)
|
13
|
-
thor (
|
13
|
+
thor (>= 0.18, < 2)
|
14
14
|
byebug (11.1.3)
|
15
|
-
childprocess (
|
16
|
-
coderay (1.1.
|
15
|
+
childprocess (4.0.0)
|
16
|
+
coderay (1.1.3)
|
17
17
|
colorize (0.8.1)
|
18
|
-
diff-lcs (1.
|
18
|
+
diff-lcs (1.4.4)
|
19
19
|
docile (1.3.2)
|
20
20
|
fasterer (0.8.3)
|
21
21
|
colorize (~> 0.7)
|
22
22
|
ruby_parser (>= 3.14.1)
|
23
|
-
ffaker (2.
|
23
|
+
ffaker (2.17.0)
|
24
24
|
iniparse (1.5.0)
|
25
|
-
|
26
|
-
json (2.3.0)
|
25
|
+
json (2.3.1)
|
27
26
|
json_matchers (0.11.1)
|
28
27
|
json_schema
|
29
|
-
json_schema (0.20.
|
28
|
+
json_schema (0.20.9)
|
30
29
|
kwalify (0.7.2)
|
31
30
|
method_source (1.0.0)
|
32
|
-
overcommit (0.
|
33
|
-
childprocess (>= 0.6.3, <
|
31
|
+
overcommit (0.57.0)
|
32
|
+
childprocess (>= 0.6.3, < 5)
|
34
33
|
iniparse (~> 1.4)
|
35
|
-
parallel (1.19.
|
36
|
-
parser (2.7.
|
37
|
-
ast (~> 2.4.
|
34
|
+
parallel (1.19.2)
|
35
|
+
parser (2.7.2.0)
|
36
|
+
ast (~> 2.4.1)
|
38
37
|
pry (0.13.1)
|
39
38
|
coderay (~> 1.1)
|
40
39
|
method_source (~> 1.0)
|
41
40
|
pry-byebug (3.9.0)
|
42
41
|
byebug (~> 11.0)
|
43
42
|
pry (~> 0.13.0)
|
44
|
-
psych (3.
|
43
|
+
psych (3.2.0)
|
45
44
|
rainbow (3.0.0)
|
46
45
|
rake (13.0.1)
|
47
|
-
reek (6.0.
|
46
|
+
reek (6.0.2)
|
48
47
|
kwalify (~> 0.7.0)
|
49
48
|
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
50
|
-
psych (~> 3.1
|
49
|
+
psych (~> 3.1)
|
51
50
|
rainbow (>= 2.0, < 4.0)
|
51
|
+
regexp_parser (1.8.2)
|
52
|
+
rexml (3.2.4)
|
52
53
|
rspec (3.9.0)
|
53
54
|
rspec-core (~> 3.9.0)
|
54
55
|
rspec-expectations (~> 3.9.0)
|
55
56
|
rspec-mocks (~> 3.9.0)
|
56
|
-
rspec-core (3.9.
|
57
|
+
rspec-core (3.9.3)
|
57
58
|
rspec-support (~> 3.9.3)
|
58
59
|
rspec-expectations (3.9.2)
|
59
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -62,21 +63,26 @@ GEM
|
|
62
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
64
|
rspec-support (~> 3.9.0)
|
64
65
|
rspec-support (3.9.3)
|
65
|
-
rubocop (0.
|
66
|
-
jaro_winkler (~> 1.5.1)
|
66
|
+
rubocop (0.93.1)
|
67
67
|
parallel (~> 1.10)
|
68
|
-
parser (>= 2.7.
|
68
|
+
parser (>= 2.7.1.5)
|
69
69
|
rainbow (>= 2.2.2, < 4.0)
|
70
|
+
regexp_parser (>= 1.8)
|
71
|
+
rexml
|
72
|
+
rubocop-ast (>= 0.6.0)
|
70
73
|
ruby-progressbar (~> 1.7)
|
71
|
-
unicode-display_width (>= 1.4.0, <
|
72
|
-
rubocop-
|
73
|
-
|
74
|
-
rubocop-
|
75
|
-
rubocop (>= 0.
|
74
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
75
|
+
rubocop-ast (0.8.0)
|
76
|
+
parser (>= 2.7.1.5)
|
77
|
+
rubocop-performance (1.8.1)
|
78
|
+
rubocop (>= 0.87.0)
|
79
|
+
rubocop-ast (>= 0.4.0)
|
80
|
+
rubocop-rspec (1.43.2)
|
81
|
+
rubocop (~> 0.87)
|
76
82
|
ruby-progressbar (1.10.1)
|
77
|
-
ruby_parser (3.
|
83
|
+
ruby_parser (3.15.0)
|
78
84
|
sexp_processor (~> 4.9)
|
79
|
-
sexp_processor (4.
|
85
|
+
sexp_processor (4.15.1)
|
80
86
|
simplecov (0.17.1)
|
81
87
|
docile (~> 1.1)
|
82
88
|
json (>= 1.8, < 3)
|
@@ -84,35 +90,35 @@ GEM
|
|
84
90
|
simplecov-html (0.10.2)
|
85
91
|
simpleidn (0.1.1)
|
86
92
|
unf (~> 0.1.4)
|
87
|
-
thor (0.
|
88
|
-
truemail-rspec (0.1
|
93
|
+
thor (1.0.1)
|
94
|
+
truemail-rspec (0.2.1)
|
89
95
|
rspec (~> 3.9)
|
90
96
|
truemail (~> 1.4, >= 1.4.1)
|
91
97
|
unf (0.1.4)
|
92
98
|
unf_ext
|
93
99
|
unf_ext (0.0.7.7)
|
94
|
-
unicode-display_width (1.
|
100
|
+
unicode-display_width (1.7.0)
|
95
101
|
|
96
102
|
PLATFORMS
|
97
103
|
ruby
|
98
104
|
|
99
105
|
DEPENDENCIES
|
100
106
|
bundler (~> 1.16)
|
101
|
-
bundler-audit (~> 0.
|
107
|
+
bundler-audit (~> 0.7.0.1)
|
102
108
|
fasterer (~> 0.8.3)
|
103
|
-
ffaker (~> 2.
|
109
|
+
ffaker (~> 2.17)
|
104
110
|
json_matchers (~> 0.11.1)
|
105
|
-
overcommit (~> 0.
|
111
|
+
overcommit (~> 0.57.0)
|
106
112
|
pry-byebug (~> 3.9)
|
107
113
|
rake (~> 13.0, >= 13.0.1)
|
108
|
-
reek (~> 6.0)
|
114
|
+
reek (~> 6.0, >= 6.0.2)
|
109
115
|
rspec (~> 3.9)
|
110
|
-
rubocop (~> 0.
|
111
|
-
rubocop-performance (~> 1.
|
112
|
-
rubocop-rspec (~> 1.
|
116
|
+
rubocop (~> 0.93.1)
|
117
|
+
rubocop-performance (~> 1.8, >= 1.8.1)
|
118
|
+
rubocop-rspec (~> 1.43, >= 1.43.2)
|
113
119
|
simplecov (~> 0.17.1)
|
114
120
|
truemail!
|
115
|
-
truemail-rspec (~> 0.1
|
121
|
+
truemail-rspec (~> 0.2.1)
|
116
122
|
|
117
123
|
BUNDLED WITH
|
118
124
|
1.16.6
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2019 Vladislav Trotsenko
|
3
|
+
Copyright (c) 2019-2020 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
@@ -1,9 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# ![Truemail - configurable framework agnostic plain Ruby email validator](https://truemail-rb.org/assets/images/truemail_logo.png)
|
2
2
|
|
3
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/0fea6d2e64d78d66b149/maintainability)](https://codeclimate.com/github/truemail-rb/truemail/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/0fea6d2e64d78d66b149/test_coverage)](https://codeclimate.com/github/truemail-rb/truemail/test_coverage) [![CircleCI](https://circleci.com/gh/truemail-rb/truemail/tree/master.svg?style=svg)](https://circleci.com/gh/truemail-rb/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
|
|
7
|
+
> Actual and maintainable documentation :books: for developers is living [here](https://truemail-rb.org/truemail-gem).
|
8
|
+
|
7
9
|
## Table of Contents
|
8
10
|
|
9
11
|
- [Synopsis](#synopsis)
|
@@ -32,14 +34,16 @@ Configurable framework agnostic plain Ruby email validator. Verify email via Reg
|
|
32
34
|
- [SMTP validation](#smtp-validation)
|
33
35
|
- [SMTP safe check disabled](#smtp-safe-check-disabled)
|
34
36
|
- [SMTP safe check enabled](#smtp-safe-check-enabled)
|
35
|
-
- [Event logger](#event-logger)
|
36
|
-
- [Available tracking events](#available-tracking-events)
|
37
|
-
- [JSON serializer](#json-serializer)
|
38
37
|
- [Host audit features](#host-audit-features)
|
39
38
|
- [IP audit](#ip-audit)
|
40
39
|
- [DNS audit](#dns-audit)
|
41
40
|
- [PTR audit](#ptr-audit)
|
42
41
|
- [Example of using](#example-of-using)
|
42
|
+
- [Event logger](#event-logger)
|
43
|
+
- [Available tracking events](#available-tracking-events)
|
44
|
+
- [JSON serializers](#json-serializers)
|
45
|
+
- [Auditor JSON serializer](#auditor-json-serializer)
|
46
|
+
- [Validator JSON serializer](#validator-json-serializer)
|
43
47
|
- [Truemail helpers](#truemail-helpers)
|
44
48
|
- [.valid?](#valid)
|
45
49
|
- [#as_json](#as_json)
|
@@ -51,11 +55,10 @@ Configurable framework agnostic plain Ruby email validator. Verify email via Reg
|
|
51
55
|
- [Credits](#credits)
|
52
56
|
- [Versioning](#versioning)
|
53
57
|
- [Changelog](CHANGELOG.md)
|
54
|
-
- [Wiki](https://github.com/rubygarage/truemail/wiki)
|
55
58
|
|
56
59
|
## Synopsis
|
57
60
|
|
58
|
-
Email validation is a tricky thing. There are a number of different ways to validate an email address and all mechanisms must conform with the best practices and provide proper validation.
|
61
|
+
Email validation is a tricky thing. There are a number of different ways to validate an email address and all mechanisms must conform with the best practices and provide proper validation. The Truemail gem helps you validate emails via regex pattern, presence of DNS records, and real existence of email account on a current email server.
|
59
62
|
|
60
63
|
**Syntax Checking**: Checks the email addresses via regex pattern.
|
61
64
|
|
@@ -74,7 +77,7 @@ Also Truemail gem allows performing an audit of the host in which runs.
|
|
74
77
|
- Simple SMTP debugger
|
75
78
|
- Event logger
|
76
79
|
- Host auditor tools (helps to detect common host problems interfering to proper email verification)
|
77
|
-
- JSON
|
80
|
+
- JSON serializers
|
78
81
|
|
79
82
|
## Requirements
|
80
83
|
|
@@ -124,7 +127,7 @@ You can use global gem configuration or custom independent configuration. Availa
|
|
124
127
|
|
125
128
|
#### Setting global configuration
|
126
129
|
|
127
|
-
To have an access for
|
130
|
+
To have an access for `Truemail.configuration` and gem configuration features, you must configure it first as in the example below:
|
128
131
|
|
129
132
|
```ruby
|
130
133
|
require 'truemail'
|
@@ -286,11 +289,12 @@ Please note, you should have global or custom configuration for use Truemail gem
|
|
286
289
|
|
287
290
|
#### Whitelist/Blacklist check
|
288
291
|
|
289
|
-
Whitelist/Blacklist check is zero validation level. You can define white and black list domains. It means that validation of email which contains whitelisted domain always will return
|
292
|
+
Whitelist/Blacklist check is zero validation level. You can define white and black list domains. It means that validation of email which contains whitelisted domain always will return `true`, and for blacklisted domain will return `false`.
|
290
293
|
|
291
|
-
Please note, other validations will not processed even if it was defined in
|
294
|
+
Please note, other validations will not processed even if it was defined in `validation_type_for`.
|
292
295
|
|
293
296
|
**Sequence of domain list check:**
|
297
|
+
|
294
298
|
1. Whitelist check
|
295
299
|
2. Whitelist validation check
|
296
300
|
3. Blacklist check
|
@@ -353,8 +357,7 @@ Truemail.configure do |config|
|
|
353
357
|
end
|
354
358
|
```
|
355
359
|
|
356
|
-
When email domain in whitelist and
|
357
|
-
Validation of email which not contains whitelisted domain always will return ```false```.
|
360
|
+
When email domain in whitelist and `whitelist_validation` is sets equal to `true` validation type will be passed to other validators. Validation of email which not contains whitelisted domain always will return `false`.
|
358
361
|
|
359
362
|
###### Email has whitelisted domain
|
360
363
|
|
@@ -456,7 +459,7 @@ Truemail.validate('email@black-domain.com')
|
|
456
459
|
|
457
460
|
##### Duplication case
|
458
461
|
|
459
|
-
Validation result for this email returns
|
462
|
+
Validation result for this email returns `true`, because it was found in whitelisted domains list first. Also `validation_type` for this case will be redefined.
|
460
463
|
|
461
464
|
```ruby
|
462
465
|
Truemail.validate('email@somedomain.com')
|
@@ -588,7 +591,7 @@ In fact it's DNS validation because it checks not MX records only. DNS validatio
|
|
588
591
|
[Whitelist/Blacklist] -> [Regex validation] -> [MX validation]
|
589
592
|
```
|
590
593
|
|
591
|
-
Please note, Truemail MX validator [not performs](https://github.com/
|
594
|
+
Please note, Truemail MX validator [not performs](https://github.com/truemail-rb/truemail/issues/26) strict compliance of the [RFC 5321](https://tools.ietf.org/html/rfc5321#section-5) standard for best validation outcome.
|
592
595
|
|
593
596
|
##### RFC MX lookup flow
|
594
597
|
|
@@ -685,13 +688,13 @@ SMTP validation is a final, third validation level. This type of validation trie
|
|
685
688
|
[Whitelist/Blacklist] -> [Regex validation] -> [MX validation] -> [SMTP validation]
|
686
689
|
```
|
687
690
|
|
688
|
-
If total count of MX servers is equal to one,
|
691
|
+
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`.
|
689
692
|
|
690
693
|
By default, you don't need pass with-parameter to use it. Example of usage is specified below:
|
691
694
|
|
692
695
|
##### SMTP safe check disabled
|
693
696
|
|
694
|
-
With
|
697
|
+
With `smtp_safe_check = false`
|
695
698
|
|
696
699
|
```ruby
|
697
700
|
require 'truemail'
|
@@ -754,10 +757,7 @@ Truemail.validate('email@example.com')
|
|
754
757
|
#<struct Truemail::Validate::Smtp::Response
|
755
758
|
port_opened=true,
|
756
759
|
connection=true,
|
757
|
-
helo=
|
758
|
-
#<Net::SMTP::Response:0x0000000002d5aca8
|
759
|
-
@status="250",
|
760
|
-
@string="250 127.0.1.1 Hello example.com\n">,
|
760
|
+
helo=true,
|
761
761
|
mailfrom=
|
762
762
|
#<Net::SMTP::Response:0x0000000002d5a618
|
763
763
|
@status="250",
|
@@ -785,7 +785,7 @@ Truemail.validate('email@example.com')
|
|
785
785
|
|
786
786
|
##### SMTP safe check enabled
|
787
787
|
|
788
|
-
With
|
788
|
+
With `smtp_safe_check = true`
|
789
789
|
|
790
790
|
```ruby
|
791
791
|
require 'truemail'
|
@@ -821,10 +821,7 @@ Truemail.validate('email@example.com')
|
|
821
821
|
#<struct Truemail::Validate::Smtp::Response
|
822
822
|
port_opened=true,
|
823
823
|
connection=false,
|
824
|
-
helo=
|
825
|
-
#<Net::SMTP::Response:0x0000000002c934c8
|
826
|
-
@status="250",
|
827
|
-
@string="250 127.0.1.1\n">,
|
824
|
+
helo=true,
|
828
825
|
mailfrom=false,
|
829
826
|
rcptto=nil,
|
830
827
|
errors={:mailfrom=>"554 5.7.1 Client host blocked\n", :connection=>"server dropped connection after response"}>>,]>,
|
@@ -870,10 +867,7 @@ Truemail.validate('email@example.com')
|
|
870
867
|
#<struct Truemail::Validate::Smtp::Response
|
871
868
|
port_opened=true,
|
872
869
|
connection=true,
|
873
|
-
helo=
|
874
|
-
#<Net::SMTP::Response:0x0000000002d5aca8
|
875
|
-
@status="250",
|
876
|
-
@string="250 127.0.1.1 Hello example.com\n">,
|
870
|
+
helo=true,
|
877
871
|
mailfrom=#<Net::SMTP::Response:0x0000000002d5a618 @status="250", @string="250 OK\n">,
|
878
872
|
rcptto=false,
|
879
873
|
errors={:rcptto=>"550 User not found\n"}>>]>,
|
@@ -896,63 +890,6 @@ Truemail.validate('email@example.com')
|
|
896
890
|
@validation_type=:smtp>
|
897
891
|
```
|
898
892
|
|
899
|
-
### Event logger
|
900
|
-
|
901
|
-
Truemail gem allows to output tracking events to stdout/file or both of these. Please note, at least one of the outputs must exist. Tracking event by default is `:error`
|
902
|
-
|
903
|
-
```ruby
|
904
|
-
Truemail.configure do |config|
|
905
|
-
config.logger = { tracking_event: :all, stdout: true, log_absolute_path: '/home/app/log/truemail.log' }
|
906
|
-
end
|
907
|
-
```
|
908
|
-
|
909
|
-
#### Available tracking events
|
910
|
-
|
911
|
-
- `:all`, all detected events including success validation cases
|
912
|
-
- `:unrecognized_error`, unrecognized errors only (when `smtp_safe_check = true` and SMTP server does not return an exact answer that the email does not exist)
|
913
|
-
- `:recognized_error`, recognized errors only
|
914
|
-
- `:error`, recognized and unrecognized errors only
|
915
|
-
|
916
|
-
### JSON serializer
|
917
|
-
|
918
|
-
Truemail has built in JSON serializer for `Truemail::Validator` instance, so you can represent your email validation result as json.
|
919
|
-
|
920
|
-
```ruby
|
921
|
-
Truemail::Log::Serializer::Json.call(Truemail.validate('nonexistent_email@bestweb.com.ua'))
|
922
|
-
|
923
|
-
=>
|
924
|
-
# Serialized Truemail::Validator instance
|
925
|
-
{
|
926
|
-
"date": "2019-10-28 10:15:51 +0200",
|
927
|
-
"email": "nonexistent_email@bestweb.com.ua",
|
928
|
-
"validation_type": "smtp",
|
929
|
-
"success": false,
|
930
|
-
"errors": {
|
931
|
-
"smtp": "smtp error"
|
932
|
-
},
|
933
|
-
"smtp_debug": [
|
934
|
-
{
|
935
|
-
"mail_host": "213.180.193.89",
|
936
|
-
"port_opened": true,
|
937
|
-
"connection": true,
|
938
|
-
"errors": {
|
939
|
-
"rcptto": "550 5.7.1 No such user!\n"
|
940
|
-
}
|
941
|
-
}
|
942
|
-
],
|
943
|
-
"configuration": {
|
944
|
-
"validation_type_by_domain": null,
|
945
|
-
"whitelist_validation": false,
|
946
|
-
"whitelisted_domains": null,
|
947
|
-
"blacklisted_domains": null,
|
948
|
-
"not_rfc_mx_lookup_flow": false,
|
949
|
-
"smtp_safe_check": false,
|
950
|
-
"email_pattern": "default gem value",
|
951
|
-
"smtp_error_body_pattern": "default gem value"
|
952
|
-
}
|
953
|
-
}
|
954
|
-
```
|
955
|
-
|
956
893
|
### Host audit features
|
957
894
|
|
958
895
|
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.
|
@@ -1004,8 +941,8 @@ Truemail.host_audit
|
|
1004
941
|
#<struct Truemail::Auditor::Result
|
1005
942
|
current_host_ip="127.0.0.1",
|
1006
943
|
warnings={
|
1007
|
-
:dns=>"
|
1008
|
-
:ptr=>"
|
944
|
+
:dns=>"A-record of verifier domain not refers to current host ip address",
|
945
|
+
:ptr=>"PTR-record does not reference to current verifier domain"
|
1009
946
|
},
|
1010
947
|
configuration=
|
1011
948
|
#<Truemail::Configuration:0x00005615e86327a8
|
@@ -1025,6 +962,91 @@ Truemail.host_audit
|
|
1025
962
|
@whitelisted_domains=[]>
|
1026
963
|
```
|
1027
964
|
|
965
|
+
### Event logger
|
966
|
+
|
967
|
+
Truemail gem allows to output tracking events to stdout/file or both of these. Please note, at least one of the outputs must exist. Tracking event by default is `:error`
|
968
|
+
|
969
|
+
```ruby
|
970
|
+
Truemail.configure do |config|
|
971
|
+
config.logger = { tracking_event: :all, stdout: true, log_absolute_path: '/home/app/log/truemail.log' }
|
972
|
+
end
|
973
|
+
```
|
974
|
+
|
975
|
+
#### Available tracking events
|
976
|
+
|
977
|
+
- `:all`, all detected events including success validation cases
|
978
|
+
- `:unrecognized_error`, unrecognized errors only (when `smtp_safe_check = true` and SMTP server does not return an exact answer that the email does not exist)
|
979
|
+
- `:recognized_error`, recognized errors only
|
980
|
+
- `:error`, recognized and unrecognized errors only
|
981
|
+
|
982
|
+
### JSON serializers
|
983
|
+
|
984
|
+
Truemail has built in JSON serializers for `Truemail::Auditor` and `Truemail::Validator` instances, so you can represent your host audition or email validation result as json. Also you can use [#as_json](#as_json) helper for shortcuting.
|
985
|
+
|
986
|
+
#### Auditor JSON serializer
|
987
|
+
|
988
|
+
```ruby
|
989
|
+
Truemail::Log::Serializer::AuditorJson.call(Truemail.host_audit)
|
990
|
+
|
991
|
+
=>
|
992
|
+
# Serialized Truemail::Auditor instance
|
993
|
+
{
|
994
|
+
"date": "2020-08-31 22:33:43 +0300",
|
995
|
+
"current_host_ip": "127.0.0.1",
|
996
|
+
"warnings": {
|
997
|
+
"dns": "A-record of verifier domain not refers to current host ip address", "ptr": "PTR-record does not reference to current verifier domain"
|
998
|
+
},
|
999
|
+
"configuration": {
|
1000
|
+
"validation_type_by_domain": null,
|
1001
|
+
"whitelist_validation": false,
|
1002
|
+
"whitelisted_domains": null,
|
1003
|
+
"blacklisted_domains": null,
|
1004
|
+
"not_rfc_mx_lookup_flow": false,
|
1005
|
+
"smtp_safe_check": false,
|
1006
|
+
"email_pattern": "default gem value",
|
1007
|
+
"smtp_error_body_pattern": "default gem value"
|
1008
|
+
}
|
1009
|
+
}
|
1010
|
+
```
|
1011
|
+
|
1012
|
+
#### Validator JSON serializer
|
1013
|
+
|
1014
|
+
```ruby
|
1015
|
+
Truemail::Log::Serializer::ValidatorJson.call(Truemail.validate('nonexistent_email@bestweb.com.ua'))
|
1016
|
+
|
1017
|
+
=>
|
1018
|
+
# Serialized Truemail::Validator instance
|
1019
|
+
{
|
1020
|
+
"date": "2019-10-28 10:15:51 +0200",
|
1021
|
+
"email": "nonexistent_email@bestweb.com.ua",
|
1022
|
+
"validation_type": "smtp",
|
1023
|
+
"success": false,
|
1024
|
+
"errors": {
|
1025
|
+
"smtp": "smtp error"
|
1026
|
+
},
|
1027
|
+
"smtp_debug": [
|
1028
|
+
{
|
1029
|
+
"mail_host": "213.180.193.89",
|
1030
|
+
"port_opened": true,
|
1031
|
+
"connection": true,
|
1032
|
+
"errors": {
|
1033
|
+
"rcptto": "550 5.7.1 No such user!\n"
|
1034
|
+
}
|
1035
|
+
}
|
1036
|
+
],
|
1037
|
+
"configuration": {
|
1038
|
+
"validation_type_by_domain": null,
|
1039
|
+
"whitelist_validation": false,
|
1040
|
+
"whitelisted_domains": null,
|
1041
|
+
"blacklisted_domains": null,
|
1042
|
+
"not_rfc_mx_lookup_flow": false,
|
1043
|
+
"smtp_safe_check": false,
|
1044
|
+
"email_pattern": "default gem value",
|
1045
|
+
"smtp_error_body_pattern": "default gem value"
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
```
|
1049
|
+
|
1028
1050
|
### Truemail helpers
|
1029
1051
|
|
1030
1052
|
#### .valid?
|
@@ -1039,9 +1061,32 @@ Truemail.valid?('email@example.com')
|
|
1039
1061
|
|
1040
1062
|
#### #as_json
|
1041
1063
|
|
1042
|
-
You can use `#as_json` helper for represent `Truemail::Validator`
|
1064
|
+
You can use `#as_json` helper for represent `Truemail::Auditor` or `Truemail::Validator` instances as json. Under the hood it uses internal json `Truemail::Log::Serializer::AuditorJson` and `Truemail::Log::Serializer::ValidatorJson` [serializers](#json-serializers):
|
1043
1065
|
|
1044
1066
|
```ruby
|
1067
|
+
Truemail.host_audit.as_json
|
1068
|
+
|
1069
|
+
=>
|
1070
|
+
# Serialized Truemail::Auditor instance
|
1071
|
+
{
|
1072
|
+
"date": "2020-08-31 22:33:43 +0300",
|
1073
|
+
"current_host_ip": "127.0.0.1",
|
1074
|
+
"warnings": {
|
1075
|
+
"dns": "A-record of verifier domain not refers to current host ip address", "ptr": "PTR-record does not reference to current verifier domain"
|
1076
|
+
},
|
1077
|
+
"configuration": {
|
1078
|
+
"validation_type_by_domain": null,
|
1079
|
+
"whitelist_validation": false,
|
1080
|
+
"whitelisted_domains": null,
|
1081
|
+
"blacklisted_domains": null,
|
1082
|
+
"not_rfc_mx_lookup_flow": false,
|
1083
|
+
"smtp_safe_check": false,
|
1084
|
+
"email_pattern": "default gem value",
|
1085
|
+
"smtp_error_body_pattern": "default gem value"
|
1086
|
+
}
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
|
1045
1090
|
Truemail.validate('nonexistent_email@bestweb.com.ua').as_json
|
1046
1091
|
|
1047
1092
|
=>
|
@@ -1112,19 +1157,19 @@ end
|
|
1112
1157
|
|
1113
1158
|
## Truemail family
|
1114
1159
|
|
1115
|
-
All Truemail
|
1160
|
+
All Truemail solutions: https://truemail-rb.org
|
1116
1161
|
|
1117
1162
|
| Name | Type | Description |
|
1118
1163
|
| --- | --- | --- |
|
1119
|
-
| [truemail server](https://github.com/truemail-rb/truemail-rack) | ruby app | Lightweight rack based web API wrapper for Truemail |
|
1164
|
+
| [truemail server](https://github.com/truemail-rb/truemail-rack) | ruby app | Lightweight rack based web API wrapper for Truemail gem |
|
1120
1165
|
| [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 |
|
1122
|
-
| [truemail-crystal-client](https://github.com/truemail-rb/truemail-crystal-client) | crystal shard |
|
1123
|
-
| [truemail-rspec](https://github.com/truemail-rb/truemail-rspec) | ruby gem | Truemail configuration and validator RSpec helpers |
|
1166
|
+
| [truemail-ruby-client](https://github.com/truemail-rb/truemail-ruby-client) | ruby gem | Web API Ruby client for Truemail Server |
|
1167
|
+
| [truemail-crystal-client](https://github.com/truemail-rb/truemail-crystal-client) | crystal shard | Web API Crystal client for Truemail Server |
|
1168
|
+
| [truemail-rspec](https://github.com/truemail-rb/truemail-rspec) | ruby gem | Truemail configuration, auditor and validator RSpec helpers |
|
1124
1169
|
|
1125
1170
|
## Contributing
|
1126
1171
|
|
1127
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
1172
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/truemail-rb/truemail. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. Please check the [open tikets](https://github.com/truemail-rb/truemail/issues). Be shure to follow Contributor Code of Conduct below and our [Contributing Guidelines](CONTRIBUTING.md).
|
1128
1173
|
|
1129
1174
|
## License
|
1130
1175
|
|
@@ -1136,14 +1181,9 @@ Everyone interacting in the Truemail project’s codebases, issue trackers, chat
|
|
1136
1181
|
|
1137
1182
|
## Credits
|
1138
1183
|
|
1139
|
-
- [The Contributors](https://github.com/
|
1140
|
-
- [The Stargazers](https://github.com/
|
1184
|
+
- [The Contributors](https://github.com/truemail-rb/truemail/graphs/contributors) for code and awesome suggestions
|
1185
|
+
- [The Stargazers](https://github.com/truemail-rb/truemail/stargazers) for showing their support
|
1141
1186
|
|
1142
1187
|
## Versioning
|
1143
1188
|
|
1144
1189
|
Truemail uses [Semantic Versioning 2.0.0](https://semver.org)
|
1145
|
-
|
1146
|
-
---
|
1147
|
-
<a href="https://rubygarage.org/"><img src="https://rubygarage.s3.amazonaws.com/assets/assets/rg_color_logo_horizontal-919afc51a81d2e40cb6a0b43ee832e3fcd49669d06785156d2d16fd0d799f89e.png" alt="RubyGarage Logo" width="415" height="128"></a>
|
1148
|
-
|
1149
|
-
RubyGarage is a leading software development and consulting company in Eastern Europe. Our main expertise includes Ruby and Ruby on Rails, but we successfully employ other technologies to deliver the best results to our clients. [Check out our portfolio](https://rubygarage.org/portfolio) for even more exciting works!
|