File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1- from MailboxValidator .SingleValidation import SingleValidation
1+ from MailboxValidator .email_validation import EmailValidation
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments