IMAP SEARCH Error

R

Roopesh

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
 
J

jean-michel bain-cornu

imaplib.abort: command: SEARCH => unexpected response: '*'
Can anyone tell me why this happens ?

It looks like a server problem. What kind of server are you using ?
Exchange, Cyrus ?
Did you try with two different Imap servers ?
If it is a unix server, did you have a look in /var/log ? Or in windows
event log ?
 
T

Thomas Guettler

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

I had difficulties with the imaplib, too. It is very low level. You need
to know some parts of the IMAP protocol.

I solved my problems by checking with ethereal (wireshark) what
other applications (KMail, getmail) do.

getmail is like fetchmail, but written in Python. I found some hints
by looking at its source.

HTH,
Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top