Python imaplib Yahoo error

Discussion in 'Python' started by Linh Lee, Aug 20, 2022.

  1. Linh Lee

    Linh Lee New Member

    Joined:
    Aug 18, 2022
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Female
    Location:
    San Francisco
    Want to search folder "SPAM", for specific_user@any domain, and delete found mail.

    Code below ...
    Code:
    import imaplib
    
    box = imaplib.IMAP4_SSL('imap.mail.yahoo.com', 993)
    box.login("xxxxxxxx@yahoo.com","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()
    ... is generating these errors below, please assist in debugging, thanks.

    Code:
    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
     
  2. Linh Lee

    Linh Lee New Member

    Joined:
    Aug 18, 2022
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Female
    Location:
    San Francisco
    SOLUTION:
    Got off the phone with Yahoo Premium Support Engineer.
    Yahoo mail has a unique way of generating the "Spam" folder filtering system, thus, folder scan would not display it!
    Due to the above mentioned, 3rd party mailbox managers, can't access it by it's name, SO, an identical box called "Bulk" is generated, giving you access to all the contents of the "Spam" folder via "Bulk".
    When I ran a scan for the folders/boxes, I didn't notice that I had an extra folder called "Bulk", that only appears via the scan, and can't be seen via the web browser.
    I'm paraphrasing the above info from the engineer's explanation, hope it makes sense for anyone having the same issue.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice