Aug-20-2022, 01:41 AM
(This post was last modified: Aug-20-2022, 05:58 AM by Yoriz.
Edit Reason: Added error tags
)
Hello all,
Getting close to what I want to accomplish, below is new simplified code. I just need assistance please in debugging the errors.
What I want to accomplish:
Search folder called "SPAM", for specific_user@any domain, and delete found mail.
New code:
Getting close to what I want to accomplish, below is new simplified code. I just need assistance please in debugging the errors.
What I want to accomplish:
Search folder called "SPAM", for specific_user@any domain, and delete found mail.
New code:
import imaplib box = imaplib.IMAP4_SSL('imap.mail.yahoo.com', 993) box.login("[email protected]","xxxxxxxxxx") box.select('SPAM') typ, data = box.search(None, 'from','name@*.*') for num in data[0].split(): box.store(num, '+FLAGS', '\\Deleted') box.expunge() box.close() box.logout()Generating these errors below, please assist in debugging, thanks:
Error:Traceback (most recent call last):
File "C:\Users\Desktop\Desktop\Python Spam Buster\test.py", line 6, in <module>
typ, data = box.search(None, 'from','name@*.*')
File "C:\Users\Desktop\AppData\Local\Programs\Python\Python310\lib\imaplib.py", line 734, in search
typ, dat = self._simple_command(name, *criteria)
File "C:\Users\Desktop\AppData\Local\Programs\Python\Python310\lib\imaplib.py", line 1230, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "C:\Users\Desktop\AppData\Local\Programs\Python\Python310\lib\imaplib.py", line 968, in _command
raise self.error("command %s illegal in state %s, "
imaplib.IMAP4.error: command SEARCH illegal in state AUTH, only allowed in states SELECTED