[plug] deleting mail using imap

Craig Ringer craig at postnewspapers.com.au
Sun Apr 18 16:57:52 WST 2004


On Sat, 2004-04-17 at 14:14, Russ Powers wrote:

> If you tell me that when I delete my emails locally they should be deleted on 
> the server then I will assume I made a configuration error and go find it.

With IMAP, they should be deleted from the server when removed from the
client. HOWEVER, 'deletion' in IMAP is not complete removal. A message
that's deleted simply has the \Deleted flag set; it is not removed from
the spool. The message is only removed when the mail client next issues
an EXPUNGE command. When this is done is configurable in many clients -
for example, some offer the option of sending an EXPUNGE on exit.

I don't use kmail, so I can't help with specifics.

A good test is to manually connect to the IMAP server, and issue an
EXPUNGE command. For example:

$ telnet localhost 143
Connected to localhost.
Escape character is '^]'.
* OK bucket.localnet Cyrus IMAP4 v2.1.14 server ready
. login craig xxxxxxxxx
. OK User logged in
. SELECT INBOX
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen NonJunk $Label2
$Label1 $Label3 $Label4 $Label5 Junk $Forwarded $MDNSent)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen NonJunk
$Label2 $Label1 $Label3 $Label4 $Label5 Junk $Forwarded $MDNSent \*)]
* 66 EXISTS
* 1 RECENT
* OK [UNSEEN 65]
* OK [UIDVALIDITY 1060587836]
* OK [UIDNEXT 12786]
. OK [READ-WRITE] Completed
. EXPUNGE
. EXPUNGE
* 49 EXPUNGE
* 49 EXPUNGE
* 49 EXPUNGE
* 49 EXPUNGE
* 49 EXPUNGE
* 49 EXPUNGE
* 49 EXPUNGE
* 49 EXPUNGE
* 49 EXPUNGE
* 50 EXPUNGE
* 50 EXPUNGE
* 50 EXPUNGE
* 50 EXPUNGE
* 50 EXPUNGE
* 50 EXPUNGE
* 51 EXISTS
* 1 RECENT
. OK Completed
. LOGOUT
* BYE LOGOUT received
. OK Completed

See the list of EXPUNGEd messages? They were flagged as deleted in my
mail client, but as I haven't explicitly expunged the mailbox, nor
exited the client (mine, Evolution, is set to expunge on exit), they
were still in the spool.

The only parts of that I typed were:

. login craig xxxxxxxx
. SELECT INBOX
. EXPUNGE
. LOGOUT

the rest is server output.

Note that to connect like that, your server must permit the LOGIN
authentication method over an un-encrypted connection. Do not do this
except to the local host, as your password will be passed in plain text.

If you server doesn't support permit plaintext authentication, you can
use Python's imaplib module to do much the same thing from an
interactive python prompt, but using SSL. You'll need Python 2.3 for
imaplib.IMAP4_SSL support.

Craig Ringer




More information about the plug mailing list