-
Notifications
You must be signed in to change notification settings - Fork 0
/
mxtoolbox.py
39 lines (31 loc) · 1.22 KB
/
mxtoolbox.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import argparse
from os import environ
from dotenv import load_dotenv
from mt.mxtoolbox import mxtoolbox as mt
load_dotenv()
parser = argparse.ArgumentParser(
usage="mxtoolbox.py (-a [action]) (-l [lookup])", description="Checks whether your mail servers are blacklisted using Mxtoolbox REST API")
parser.add_argument('-a', metavar='', type=str, nargs=1,
help='pick one action: monitor, usage. For lookup use "-l"')
parser.add_argument('-r', action='store_true',
help='use for raw input')
parser.add_argument('-l', metavar=' lookup', type=str, nargs=1,
help='Give lookup type: smtp, mx, ...(https://mxtoolbox.com/SuperTool.aspx)')
args = parser.parse_args()
if not (args.a or args.l):
parser.error('No action requested, add -a or -l')
API = mt(key=environ.get('ENV'))
if args.l and args.r:
stool = input('What do you want to lookup?\n>> ')
print(API.lookup(command=args.l[0], argument=stool, RAW=True))
quit()
elif args.l:
stool = input('What do you want to lookup?\n>> ')
print(API.lookup(command=args.l[0], argument=stool))
quit()
run = getattr(API, args.a[0])
if args.a and args.r:
print(run(RAW=True))
quit()
elif args.a:
print(run())