Greetings friends,
My first post, very new to programing, and I must also tell you I'm fascinated and in love with Python!!
My email account has been blasted lately from a specific user, with spoofed domain names, well over 50 per day, non stop for over 9 weeks now!! Yes, I could just place them in the Spam folder, but, it makes it hard to search for possible legit emails, and I want to use this as a Python learning process.
Want to search for user@wildcard domain, move users to folder called DUMP, then delete contents of DUMP.
Below are the 3 working sections I have:
CREDIT: Sunny Solanki in coderzcolumn.com
Please break down each piece of code, so I can try and understand what it does.
Blessings,
LL
My first post, very new to programing, and I must also tell you I'm fascinated and in love with Python!!
My email account has been blasted lately from a specific user, with spoofed domain names, well over 50 per day, non stop for over 9 weeks now!! Yes, I could just place them in the Spam folder, but, it makes it hard to search for possible legit emails, and I want to use this as a Python learning process.
Want to search for user@wildcard domain, move users to folder called DUMP, then delete contents of DUMP.
Below are the 3 working sections I have:
CREDIT: Sunny Solanki in coderzcolumn.com
import imaplib
import time
################# IMAP SSL ################################
start = time.time()
try:
imap_ssl = imaplib.IMAP4_SSL(host="imap.mail.yahoo.com", port=993)
except Exception as e:
print("ErrorType : {}, Error : {}".format(type(e).__name__, e))
imap_ssl = None
print("Connection Object : {}".format(imap_ssl))
print("Total Time Taken : {:,.2f} Seconds".format(time.time() - start))
############### Login to Mailbox ######################
print("Logging into mailbox...")
try:
resp_code, response = imap_ssl.login("[email protected]", "XXXXXXXXXXXXX")
except Exception as e:
print("ErrorType : {}, Error : {}".format(type(e).__name__, e))
resp_code, response = None, None
print("Response Code : {}".format(resp_code))
print("Response : {}\n".format(response[0].decode()))
############### Needed section to "search and destroy" ################
############### Logout of Mailbox ######################
print("\nLogging Out....")
try:
resp_code, response = imap_ssl.logout()
except Exception as e:
print("ErrorType : {}, Error : {}".format(type(e).__name__, e))
resp_code, response = None, None
print("Response Code : {}".format(resp_code))
print("Response : {}".format(response[0].decode()))I would sincerely appreciate your knowledge/expertise in helping me create the needed code section above!Please break down each piece of code, so I can try and understand what it does.
Blessings,
LL
