37 lines
901 B
Python
37 lines
901 B
Python
#!/usr/bin/env python3
|
|
|
|
from requests import get
|
|
|
|
|
|
class EmailChecker:
|
|
def __init__(self, key, email):
|
|
self._url = "https://emailrep.io"
|
|
self._headers = {
|
|
'Key': key,
|
|
'accept': 'application/json',
|
|
}
|
|
self._email = email
|
|
|
|
def reportEmailRep(self):
|
|
"""
|
|
This function get the report of the email
|
|
"""
|
|
report = dict()
|
|
|
|
res = get(
|
|
f"{self._url}/{self._email}",
|
|
headers=self._headers
|
|
)
|
|
js = res.json()
|
|
if res.status_code == 401:
|
|
report['error'] = js['reason']
|
|
return report
|
|
if res.status_code != 200:
|
|
report['error'] = 'Failed to get the report of the email'
|
|
return report
|
|
|
|
report['reputation'] = js['reputation']
|
|
report['suspicious'] = js['suspicious']
|
|
|
|
return report
|