Python Forum
Assistance debuging imaplib errors
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assistance debuging imaplib errors
#1
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:
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
Reply
#2
FOLLOWUP:
Through trial and error, I discovered Yahoo Mail Server, handles "select" request for ALL folders, both created, and system, EXCEPT one, SPAM!!

The is only one folder Yahoo Mail Server doesn't accept a select box request for, SPAM folder.
box.select('Spam')

I did a resp_code, directories = imap_ssl.list()
All directories/folders appear, both created, and system, EXCEPT one, SPAM!!

The reason for the error then is, Yahoo Mail server rejects box.select('Spam'), script is then halted, and error is generated!

Solutions/workaround anyone!?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb python code debuging yunus 1 331 Feb-11-2024, 03:48 PM
Last Post: deanhystad
  IMAPLib Has No Attribute IMAP4_SSL. Help! bmccollum 3 3,896 Jun-13-2020, 04:34 AM
Last Post: bmccollum
  imaplib problem levann 3 3,587 Jul-15-2019, 10:05 AM
Last Post: levann
  How can read and download the attachment from the mail using while loop in IMAPlib Py Samjith 0 4,272 Oct-11-2018, 07:15 AM
Last Post: Samjith
  Email Checker with IMAPlib ronaldrios 1 3,799 Jun-23-2017, 04:03 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020