Want to:
- Search ALL folders including SPAM, for “specific_user@ANY domain”
- Move those emails to folder called DUMP
- Delete contents of DUMP
Unfortunately I can’t figure out how to do what I need above in Yahoo Mail!
My code so far below:
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("xxxxxxxxx@yahoo.com", "xxxxxxxxxx")
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()))
####### Missing code to search, move and delete #######
####### 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()))