IMAP SEARCH Error

Roopesh roopesh.raj at gmail.com
Wed Jan 17 09:13:22 EST 2007


I am using the imaplib to fetch mails. There is an error thrown in the
search function, which I am not able to comprehend.

My program is as follows :
====================
import imaplib

M = imaplib.IMAP4("10.1.1.1",1143)
M.login("roopesh", "roopesh12")
type, data = M.select("INBOX", 1)

print type, data
print M.status("INBOX", '(MESSAGES UNSEEN RECENT)')

typ, data = M.search(None, '(ALL)')

print typ, data
for num in data[0].split():
    typ, data = M.fetch(num, '(RFC822)')
    print 'Message %s\n%s\n' % (num, data[0][1])
M.close()
M.logout()

And the OUTPUT in the console is as follows :
==================================

OK ['24']
('OK', ['INBOX ( MESSAGES 24 UNSEEN 0 RECENT 0)'])
Traceback (most recent call last):
  File "imap_test1.py", line 10, in ?
    typ, data = M.search(None, '(ALL)')
  File "c:\python24\lib\imaplib.py", line 602, in search
    typ, dat = self._simple_command(name, *criteria)
  File "c:\python24\lib\imaplib.py", line 1028, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "c:\python24\lib\imaplib.py", line 860, in _command_complete
    raise self.abort('command: %s => %s' % (name, val))
imaplib.abort: command: SEARCH => unexpected response: '*'

Can anyone tell me why this happens ?

Regards
Roopesh




More information about the Python-list mailing list