truemail 0.1.9 → 0.1.10
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/Gemfile.lock +2 -2
- data/README.md +8 -0
- data/lib/truemail/configuration.rb +7 -3
- data/lib/truemail/core.rb +1 -0
- data/lib/truemail/validate/base.rb +4 -0
- data/lib/truemail/validate/regex.rb +1 -1
- data/lib/truemail/validate/smtp.rb +3 -4
- data/lib/truemail/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 297e4833b9652ed239d157a21f13e54495d2f88dd1fcfe72173df718a42f3c67
|
4
|
+
data.tar.gz: 9cc876220623ff3b5b19fdf005f74332975f5fb6b2ecf6afceeb2b2b852f1c01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5af3df300ef218a2f10433294efd28a93b57979261f265d021b2cc25223845df28a9a2310dcda00ccfd75ac8de40e28a95d3991248f2e321934d215e1b67e88
|
7
|
+
data.tar.gz: f7d966fd95efc12b0eaf8a4208769abdf9f917a998edf80b29e2f0fe00d95cd93f292e9700bafb19dffd2112dbc304fdf75a89286a7949f848e63e92577154e7
|
data/.reek.yml
CHANGED
@@ -27,6 +27,7 @@ detectors:
|
|
27
27
|
exclude:
|
28
28
|
- Truemail::Validate::Smtp::Request#compose_from
|
29
29
|
- Truemail::Validator#select_validation_type
|
30
|
+
- Truemail::Validate::Base#configuration
|
30
31
|
- Truemail::Validate::Mx#null_mx?
|
31
32
|
- Truemail::Validate::Mx#a_record
|
32
33
|
- Truemail::Audit::Base#verifier_domain
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -58,6 +58,9 @@ Truemail.configure do |config|
|
|
58
58
|
# Optional parameter. You can override default regex pattern
|
59
59
|
config.email_pattern = /regex_pattern/
|
60
60
|
|
61
|
+
# Optional parameter. You can override default regex pattern
|
62
|
+
config.smtp_error_body_pattern = /regex_pattern/
|
63
|
+
|
61
64
|
# Optional parameter. Connection timeout is equal to 2 ms by default.
|
62
65
|
config.connection_timeout = 1
|
63
66
|
|
@@ -92,6 +95,7 @@ Truemail.configuration
|
|
92
95
|
=> #<Truemail::Configuration:0x000055590cb17b40
|
93
96
|
@connection_timeout=1,
|
94
97
|
@email_pattern=/regex_pattern/,
|
98
|
+
@smtp_error_body_pattern=/regex_pattern/,
|
95
99
|
@response_timeout=1,
|
96
100
|
@connection_attempts=3,
|
97
101
|
@validation_type_by_domain={},
|
@@ -114,6 +118,7 @@ Truemail.configuration
|
|
114
118
|
=> #<Truemail::Configuration:0x000055590cb17b40
|
115
119
|
@connection_timeout=3,
|
116
120
|
@email_pattern=/regex_pattern/,
|
121
|
+
@smtp_error_body_pattern=/regex_pattern/,
|
117
122
|
@response_timeout=4,
|
118
123
|
@connection_attempts=1,
|
119
124
|
@validation_type_by_domain={},
|
@@ -270,6 +275,7 @@ Truemail.validate('email@example.com')
|
|
270
275
|
#<Truemail::Configuration:0x0000000002d49930
|
271
276
|
@connection_timeout=2,
|
272
277
|
@email_pattern=/regex_pattern/,
|
278
|
+
@smtp_error_body_pattern=/regex_pattern/,
|
273
279
|
@response_timeout=2,
|
274
280
|
@connection_attempts=2,
|
275
281
|
@smtp_safe_check=false,
|
@@ -323,6 +329,7 @@ Truemail.validate('email@example.com')
|
|
323
329
|
#<Truemail::Configuration:0x0000000002c95b38
|
324
330
|
@connection_timeout=2,
|
325
331
|
@email_pattern=/regex_pattern/,
|
332
|
+
@smtp_error_body_pattern=/regex_pattern/,
|
326
333
|
@response_timeout=2,
|
327
334
|
@connection_attempts=2,
|
328
335
|
@smtp_safe_check=true,
|
@@ -360,6 +367,7 @@ Truemail.validate('email@example.com')
|
|
360
367
|
#<Truemail::Configuration:0x0000000002d49930
|
361
368
|
@connection_timeout=2,
|
362
369
|
@email_pattern=/regex_pattern/,
|
370
|
+
@smtp_error_body_pattern=/regex_pattern/,
|
363
371
|
@response_timeout=2,
|
364
372
|
@connection_attempts=2,
|
365
373
|
@smtp_safe_check=true,
|
@@ -7,6 +7,7 @@ module Truemail
|
|
7
7
|
DEFAULT_CONNECTION_ATTEMPTS = 2
|
8
8
|
|
9
9
|
attr_reader :email_pattern,
|
10
|
+
:smtp_error_body_pattern,
|
10
11
|
:verifier_email,
|
11
12
|
:verifier_domain,
|
12
13
|
:connection_timeout,
|
@@ -20,6 +21,7 @@ module Truemail
|
|
20
21
|
|
21
22
|
def initialize
|
22
23
|
@email_pattern = Truemail::RegexConstant::REGEX_EMAIL_PATTERN
|
24
|
+
@smtp_error_body_pattern = Truemail::RegexConstant::REGEX_SMTP_ERROR_BODY_PATTERN
|
23
25
|
@connection_timeout = Truemail::Configuration::DEFAULT_CONNECTION_TIMEOUT
|
24
26
|
@response_timeout = Truemail::Configuration::DEFAULT_RESPONSE_TIMEOUT
|
25
27
|
@connection_attempts = Truemail::Configuration::DEFAULT_CONNECTION_ATTEMPTS
|
@@ -27,9 +29,11 @@ module Truemail
|
|
27
29
|
@smtp_safe_check = false
|
28
30
|
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
%i[email_pattern smtp_error_body_pattern].each do |method|
|
33
|
+
define_method("#{method}=") do |argument|
|
34
|
+
raise Truemail::ArgumentError.new(argument, __method__) unless argument.is_a?(Regexp)
|
35
|
+
instance_variable_set(:"@#{method}", argument)
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
def verifier_email=(email)
|
data/lib/truemail/core.rb
CHANGED
@@ -21,6 +21,7 @@ module Truemail
|
|
21
21
|
REGEX_EMAIL_PATTERN = /(?=\A.{6,255}\z)(\A([a-zA-Z0-9]+[\w|\-|\.|\+]*)@(#{REGEX_DOMAIN})\z)/
|
22
22
|
REGEX_DOMAIN_PATTERN = /(?=\A.{4,255}\z)(\A#{REGEX_DOMAIN}\z)/
|
23
23
|
REGEX_DOMAIN_FROM_EMAIL = /\A.+@(.+)\z/
|
24
|
+
REGEX_SMTP_ERROR_BODY_PATTERN = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i
|
24
25
|
end
|
25
26
|
|
26
27
|
module Audit
|
@@ -6,7 +6,7 @@ module Truemail
|
|
6
6
|
ERROR = 'email does not match the regular expression'
|
7
7
|
|
8
8
|
def run
|
9
|
-
return true if success(
|
9
|
+
return true if success(configuration.email_pattern.match?(result.email))
|
10
10
|
add_error(Truemail::Validate::Regex::ERROR)
|
11
11
|
false
|
12
12
|
end
|
@@ -4,7 +4,6 @@ module Truemail
|
|
4
4
|
module Validate
|
5
5
|
class Smtp < Truemail::Validate::Base
|
6
6
|
ERROR = 'smtp error'
|
7
|
-
ERROR_BODY = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i
|
8
7
|
|
9
8
|
attr_reader :smtp_results
|
10
9
|
|
@@ -31,7 +30,7 @@ module Truemail
|
|
31
30
|
|
32
31
|
def attempts
|
33
32
|
@attempts ||=
|
34
|
-
mail_servers.one? ? { attempts:
|
33
|
+
mail_servers.one? ? { attempts: configuration.connection_attempts } : {}
|
35
34
|
end
|
36
35
|
|
37
36
|
def rcptto_error
|
@@ -53,11 +52,11 @@ module Truemail
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def not_includes_user_not_found_errors?
|
56
|
-
return unless
|
55
|
+
return unless configuration.smtp_safe_check
|
57
56
|
result.smtp_debug.map(&:response).map(&:errors).all? do |errors|
|
58
57
|
next true unless errors.key?(:rcptto)
|
59
58
|
errors.slice(:rcptto).values.none? do |error|
|
60
|
-
|
59
|
+
configuration.smtp_error_body_pattern.match?(error)
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
data/lib/truemail/version.rb
CHANGED
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: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|