Skip to content

Commit a6817d1

Browse files
Updated code to comply with Python code standard.
1 parent ad64c09 commit a6817d1

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

MailboxValidator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from MailboxValidator.SingleValidation import SingleValidation
1+
from MailboxValidator.email_validation import EmailValidation
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import http.client
2+
import urllib
3+
import hashlib
4+
import json
5+
6+
class EmailValidation:
7+
def __init__(self, apikey):
8+
self.apikey = apikey
9+
10+
def validate_email(self, email):
11+
p = { 'key': self.apikey, 'format': 'json', 'email': email }
12+
13+
try:
14+
conn = http.client.HTTPConnection("api.mailboxvalidator.com")
15+
conn.request("GET", "/v1/validation/single?" + urllib.parse.urlencode(p))
16+
res = conn.getresponse()
17+
# print res.read()
18+
return json.loads(res.read())
19+
except:
20+
return None
21+
22+
def is_disposable_email(self, email):
23+
p = { 'key': self.apikey, 'format': 'json', 'email': email }
24+
25+
try:
26+
conn = http.client.HTTPConnection("api.mailboxvalidator.com")
27+
conn.request("GET", "/v1/email/disposable?" + urllib.parse.urlencode(p))
28+
res = conn.getresponse()
29+
# print res.read()
30+
return json.loads(res.read())
31+
except:
32+
return None
33+
34+
def is_free_email(self, email):
35+
p = { 'key': self.apikey, 'format': 'json', 'email': email }
36+
37+
try:
38+
conn = http.client.HTTPConnection("api.mailboxvalidator.com")
39+
conn.request("GET", "/v1/email/free?" + urllib.parse.urlencode(p))
40+
res = conn.getresponse()
41+
# print res.read()
42+
return json.loads(res.read())
43+
except:
44+
return None

0 commit comments

Comments
 (0)