Please, friends, I am stuck once again. I want to use python to check the MX records of and email list and check if the MX record appears on another list and if yes will print the email and the matching MX record below is the code I managed to come up with.
import dns
import os
import re
import sys
with open('domain.txt') as f:
for line in f:
#do not forget to strip the trailing new line
email = line.rstrip("\n")
# print (email)
j = open("saved_mxRecord.txt")
list = j.readlines()
domain = email.split("@")[-1]
try:
records = dns.resolver.query(domain, 'MX')
mxRecord = records[0].exchange
new_mxRecord = str(mxRecord)
if new_mxRecord in range(list):
print(new_mxRecord)
print email
except Exception:
pass
when I remove this line of code if new_mxRecord in range(list):
I am able to have it spring but the major function is removed. Please how do I get to check if the new_mxRecord exists on the saved_mxRecord and have it printed out.