email_address 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/email_address.gemspec +2 -1
- data/lib/email_address/address.rb +4 -0
- data/lib/email_address/host.rb +8 -7
- data/lib/email_address/version.rb +1 -1
- data/test/email_address/test_address.rb +2 -0
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6784502377cd86fe2b6bb53c53ef7700673ed0317d2c96850ba0e9faad32c72
|
4
|
+
data.tar.gz: 5a558e95e390bf608225149fa2cb0948dcd9455607592e0c92156f34dced0807
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65cd1a6acccd37f3580762ba5d97e2956833c979a9fa639369385427bfe0ebf3cca693014d442ab530a005349e6fd36bce3d0b7372f432230bfcc4e0d3d15d79
|
7
|
+
data.tar.gz: 6543b62b3d0650717c81d2b25de2008fe6b898707a82c8779646364cb351654322958d38dfbf6b9420728a1eb7d6047d2d4205f0e11254e9d868930f6db74243
|
data/.github/workflows/ci.yml
CHANGED
data/email_address.gemspec
CHANGED
@@ -27,10 +27,11 @@ Gem::Specification.new do |spec|
|
|
27
27
|
else
|
28
28
|
spec.add_development_dependency "activerecord", "~> 6.1.4"
|
29
29
|
spec.add_development_dependency "sqlite3"
|
30
|
+
spec.add_development_dependency "standard", "~> 1.5.0"
|
30
31
|
end
|
32
|
+
# spec.add_development_dependency "net-smtp"
|
31
33
|
spec.add_development_dependency "simplecov"
|
32
34
|
spec.add_development_dependency "pry"
|
33
|
-
spec.add_development_dependency "standard", "~> 1.1.1"
|
34
35
|
|
35
36
|
spec.add_dependency "simpleidn"
|
36
37
|
end
|
@@ -258,6 +258,10 @@ module EmailAddress
|
|
258
258
|
# Connects to host to test if user can receive email. This should NOT be performed
|
259
259
|
# as an email address check, but is provided to assist in problem resolution.
|
260
260
|
# If you abuse this, you *could* be blocked by the ESP.
|
261
|
+
#
|
262
|
+
# NOTE: As of Ruby 3.1, Net::SMTP was moved from the standard library to the
|
263
|
+
# 'net-smtp' gem. In order to avoid adding that dependency for this experimental
|
264
|
+
# feature, please add the gem to your Gemfile and require it to use this feature.
|
261
265
|
def connect
|
262
266
|
smtp = Net::SMTP.new(host_name || ip_address)
|
263
267
|
smtp.start(@config[:smtp_helo_name] || "localhost")
|
data/lib/email_address/host.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "simpleidn"
|
2
2
|
require "resolv"
|
3
|
-
require "net/smtp"
|
4
3
|
|
5
4
|
module EmailAddress
|
6
5
|
##############################################################################
|
@@ -402,11 +401,7 @@ module EmailAddress
|
|
402
401
|
# True if the host name has a DNS A Record
|
403
402
|
def valid_dns?
|
404
403
|
return true unless dns_enabled?
|
405
|
-
|
406
|
-
if localhost? && !@config[:host_local]
|
407
|
-
bool = set_error(:domain_no_localhost)
|
408
|
-
end
|
409
|
-
bool
|
404
|
+
dns_a_record.size > 0 || set_error(:domain_unknown)
|
410
405
|
end
|
411
406
|
|
412
407
|
# True if the host name has valid MX servers configured in DNS
|
@@ -430,7 +425,9 @@ module EmailAddress
|
|
430
425
|
# True if the host_name passes Regular Expression match and size limits.
|
431
426
|
def valid_format?
|
432
427
|
if host_name =~ CANONICAL_HOST_REGEX && to_s.size <= MAX_HOST_LENGTH
|
433
|
-
|
428
|
+
if localhost?
|
429
|
+
return @config[:host_local] ? true : set_error(:domain_no_localhost)
|
430
|
+
end
|
434
431
|
return true if host_name.include?(".") # require FQDN
|
435
432
|
end
|
436
433
|
set_error(:domain_invalid)
|
@@ -462,6 +459,10 @@ module EmailAddress
|
|
462
459
|
# Connects to host to test it can receive email. This should NOT be performed
|
463
460
|
# as an email address check, but is provided to assist in problem resolution.
|
464
461
|
# If you abuse this, you *could* be blocked by the ESP.
|
462
|
+
#
|
463
|
+
# NOTE: As of Ruby 3.1, Net::SMTP was moved from the standard library to the
|
464
|
+
# 'net-smtp' gem. In order to avoid adding that dependency for this experimental
|
465
|
+
# feature, please add the gem to your Gemfile and require it to use this feature.
|
465
466
|
def connect
|
466
467
|
smtp = Net::SMTP.new(host_name || ip_address)
|
467
468
|
smtp.start(@config[:helo_name] || "localhost")
|
@@ -104,6 +104,8 @@ class TestAddress < Minitest::Test
|
|
104
104
|
assert_equal EmailAddress.error("user1"), "Invalid Domain Name"
|
105
105
|
assert_equal EmailAddress.error("user1", host_local: true), "This domain is not configured to accept email"
|
106
106
|
assert_equal EmailAddress.error("user1@localhost", host_local: true), "This domain is not configured to accept email"
|
107
|
+
assert_equal EmailAddress.error("user1@localhost", host_local: false, host_validation: :syntax), "localhost is not allowed for your domain name"
|
108
|
+
assert_equal EmailAddress.error("user1@localhost", host_local: false, dns_lookup: :off), "localhost is not allowed for your domain name"
|
107
109
|
assert_nil EmailAddress.error("user2@localhost", host_local: true, dns_lookup: :off, host_validation: :syntax)
|
108
110
|
end
|
109
111
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_address
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Fair
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -81,21 +81,21 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: standard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.5.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.5.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,19 +109,19 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: pry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: simpleidn
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
198
|
+
rubygems_version: 3.3.3
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: This gem provides a ruby language library for working with and validating
|