parsing IMAP responses?

G

Grant Edwards

According to Google, the question has come up before, but there
doesn't seem to be much of an answer.

The imaplib module return values are mostly useless as-is:
they're just whatever string the server sent (or in some cases
a list of strings). You've got to parse them using the IMAP
syntax before you can do much with them.

Is there a library somewhere that impliments the IMAP protocol
syntax?
 
P

Paul Rubin

Grant Edwards said:
The imaplib module return values are mostly useless as-is:
they're just whatever string the server sent (or in some cases
a list of strings). You've got to parse them using the IMAP
syntax before you can do much with them.

Is there a library somewhere that impliments the IMAP protocol
syntax?

It's very messy. I don't know of one that's in distribution. I think
there's one buried inside a certain commercial product. I wrote one a
while back that is currently inaccessible (disk crash, need to get it
recovered) but it's not really useable. IMAP syntax is very very messy.
Are you trying to write an IMAP server?
 
G

Grant Edwards

It's very messy.

It sure is. You'd think something intended to be
machine-readable would be easier to parse.
I don't know of one that's in distribution.

That's what I thought based on my Google results, but I thought
I'd ask.
I think there's one buried inside a certain commercial
product. I wrote one a while back that is currently
inaccessible (disk crash, need to get it recovered) but it's
not really useable. IMAP syntax is very very messy. Are you
trying to write an IMAP server?

No, I'm writing a client, and I was a bit surprised to find out
that imaplib doesn't really parse the responses at all. Since
I'm writing a client I only have to parse the responses to the
commands that I actually send, but it still a bit messy.
 
F

Fredrik Lundh

Grant said:
It sure is. You'd think something intended to be machine-readable
would be easier to parse.

nobody knows what the IMAP protocol designers intended...

(it's not quite as bad as Netscape's Mork format, but it's pretty close)

</F>
 
A

Alan Kennedy

[Grant Edwards]
[Paul Rubin]
[Grant Edwards]
> It sure is. You'd think something intended to be
> machine-readable would be easier to parse.

IMHO, email is the most disgracefully badly spec'ced "application" in
existence: I'm sure the average modern-day scr1pt k1dd13 could do better.

SMTP: Have you ever tried to bounce processing? PITA.

POP: No virtual hosting support.

IMAP: You are in a twisty maze of passages, each slightly different .....

It's no wonder the spammers can ply their trade with such ease.

grumpily-y'rs,
 

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,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top