mailshield 1.4 → 1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailshield/disposable_domains.rb +4 -4
- data/lib/mailshield/version.rb +2 -2
- data/lib/mailshield.rb +22 -5
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 951a883218a7b24ca485ad6e34755a420a754931ebb5590438e5ae3715ba385a
|
4
|
+
data.tar.gz: 74522e2cc5992814083ebb6235a849ff0429f9482bcdec848911526511a386cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbc024e630f232ff8bb84fff735076c0f8b9c698a12874dc622b4fda4885b4daf7574a830a8acd109d2b3e57fc9265b877516556de71b936b9e3c22f32d01a7e
|
7
|
+
data.tar.gz: 87b6a352c1e0307983ffae13f9675e97712d7c786ce39a84a4e09c0a9c6d3764a1c756fdd18ca4aabdb8fd08c11667d5dcdf8e8beaf0fd08322dc657bd13ff77
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'set'
|
3
3
|
|
4
|
+
|
4
5
|
module MailShield
|
5
6
|
KNOWN_DISPOSABLE_DOMAINS = Set.new(
|
6
7
|
[
|
@@ -85,10 +86,9 @@ module MailShield
|
|
85
86
|
]
|
86
87
|
)
|
87
88
|
|
88
|
-
|
89
89
|
class << self
|
90
|
-
def validate_known_disposal_domain?(domain)
|
91
|
-
|
90
|
+
def validate_known_disposal_domain?(domain)
|
91
|
+
raise TemporaryDomainError, 'Temporary / Disposal Email.' if KNOWN_DISPOSABLE_DOMAINS.include?(domain)
|
92
92
|
end
|
93
93
|
end
|
94
|
-
end
|
94
|
+
end
|
data/lib/mailshield/version.rb
CHANGED
data/lib/mailshield.rb
CHANGED
@@ -18,21 +18,32 @@ module MailShield
|
|
18
18
|
class SMTPError < ValidationError; end
|
19
19
|
class TemporaryDomainError < ValidationError; end
|
20
20
|
class << self
|
21
|
-
attr_accessor :dns_cache, :smtp_cache
|
21
|
+
attr_accessor :dns_cache, :smtp_cache, :whitelist, :blacklist
|
22
22
|
|
23
|
-
def
|
23
|
+
def configure
|
24
|
+
@whitelist ||= []
|
25
|
+
@blacklist ||= []
|
26
|
+
yield self
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_email(email)
|
24
30
|
reset_caches
|
25
31
|
|
26
32
|
domain = extract_domain(email)
|
27
33
|
|
34
|
+
return { valid: false, reason: 'Email domain is blacklisted.' } if blacklist.include?(domain)
|
35
|
+
|
36
|
+
if !whitelist.empty? && !whitelist.include?(domain)
|
37
|
+
return { valid: false, reason: 'Email domain is not whitelisted.' }
|
38
|
+
end
|
39
|
+
|
28
40
|
begin
|
29
41
|
validate_known_disposal_domain?(domain)
|
30
42
|
validate_format!(email)
|
31
43
|
validate_domain!(domain)
|
32
44
|
validate_spf!(domain)
|
33
45
|
validate_dmarc!(domain)
|
34
|
-
validate_smtp!(email)
|
35
|
-
|
46
|
+
validate_smtp!(email)
|
36
47
|
rescue ValidationError => e
|
37
48
|
return { valid: false, reason: e.message }
|
38
49
|
end
|
@@ -40,10 +51,16 @@ module MailShield
|
|
40
51
|
{ valid: true }
|
41
52
|
end
|
42
53
|
|
43
|
-
|
54
|
+
# Added Support for verifying email existance in real world
|
55
|
+
def email_exists?(email)
|
44
56
|
smtp_verify_email(email)
|
45
57
|
end
|
46
58
|
|
59
|
+
# Added Support for Email Format Validation
|
60
|
+
def valid_format?(email)
|
61
|
+
valid_email_format?(email)
|
62
|
+
end
|
63
|
+
|
47
64
|
private
|
48
65
|
|
49
66
|
def reset_caches
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailshield
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-smtp
|
@@ -63,5 +63,6 @@ requirements: []
|
|
63
63
|
rubygems_version: 3.5.18
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
|
-
summary:
|
66
|
+
summary: MailShield enhances your app’s security by blocking temporary, spam and disposable
|
67
|
+
email addresses, keeping your user data clean and reducing spam.
|
67
68
|
test_files: []
|