6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/moocher/emails.rb', line 6
def email_blacklisted?(email, details: false)
return "Email doesn't seem to be valid." if (email =~ /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i).nil?
base_url = 'https://api.moocher.io/bademail/'
unless details
response = HTTParty.get(base_url + email)
(response["response"]["email"]["blacklist"].empty? && response["response"]["source_ip"]["blacklist"].empty?) ? false : true
else
if details == true
response = HTTParty.get("https://api.moocher.io/bademail/#{email}", headers: {"Content-Type": "application/json"})
return response.parsed_response
else
"'details:' is by default set to false. You can only be set it to true."
end
end
end
|