diff -ur dovecot-1.2.11.orig/src/imap/client.c dovecot-1.2.11/src/imap/client.c
--- dovecot-1.2.11.orig/src/imap/client.c       2010-01-24 16:14:17.000000000 -0700
+++ dovecot-1.2.11/src/imap/client.c    2010-05-20 12:42:45.541027531 -0600
@@ -42,6 +42,7 @@
        client->fd_out = fd_out;
        client->input = i_stream_create_fd(fd_in, imap_max_line_length, FALSE);
        client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE);
+       client->expunged = 0;

        o_stream_set_flush_callback(client->output, client_output, client);

@@ -105,6 +106,7 @@
        static struct var_expand_table static_tab[] = {
                { 'i', NULL, "input" },
                { 'o', NULL, "output" },
+               { 'e', NULL, "expunged_count" },
                { '\0', NULL, NULL }
        };
        struct var_expand_table *tab;
@@ -115,6 +117,7 @@

        tab[0].value = dec2str(client->input->v_offset);
        tab[1].value = dec2str(client->output->offset);
+       tab[2].value = dec2str(client->expunged);

        str = t_str_new(128);
        var_expand(str, logout_format, tab);
diff -ur dovecot-1.2.11.orig/src/imap/client.h dovecot-1.2.11/src/imap/client.h
--- dovecot-1.2.11.orig/src/imap/client.h       2009-06-26 22:49:34.000000000 -0600
+++ dovecot-1.2.11/src/imap/client.h    2010-06-03 09:05:30.046807533 -0600
@@ -125,6 +125,8 @@
        /* command changing the mailbox */
        struct client_command_context *mailbox_change_lock;

+       unsigned int expunged;
+
        /* syncing marks this TRUE when it sees \Deleted flags. this is by
           EXPUNGE for Outlook-workaround. */
        unsigned int sync_seen_deletes:1;
diff -ur dovecot-1.2.11.orig/src/imap/cmd-close.c dovecot-1.2.11/src/imap/cmd-close.c
--- dovecot-1.2.11.orig/src/imap/cmd-close.c    2010-01-24 16:14:17.000000000 -0700
+++ dovecot-1.2.11/src/imap/cmd-close.c 2010-06-03 09:14:59.000551445 -0600
@@ -18,7 +18,7 @@
        client->mailbox = NULL;

        storage = mailbox_get_storage(mailbox);
-       if ((ret = imap_expunge(mailbox, NULL)) < 0)
+       if ((ret = imap_expunge(client, mailbox, NULL)) < 0)
                client_send_untagged_storage_error(client, storage);
        if (mailbox_sync(mailbox, 0, 0, NULL) < 0)
                client_send_untagged_storage_error(client, storage);
diff -ur dovecot-1.2.11.orig/src/imap/cmd-expunge.c dovecot-1.2.11/src/imap/cmd-expunge.c
--- dovecot-1.2.11.orig/src/imap/cmd-expunge.c  2010-01-24 16:14:17.000000000 -0700
+++ dovecot-1.2.11/src/imap/cmd-expunge.c       2010-06-03 09:16:17.716805309 -0600
@@ -24,7 +24,7 @@
 {
        struct client *client = cmd->client;

-       if (imap_expunge(client->mailbox, search_args == NULL ? NULL :
+       if (imap_expunge(client, client->mailbox, search_args == NULL ? NULL :
                         search_args->args) < 0) {
                client_send_storage_error(cmd,
                                          mailbox_get_storage(client->mailbox));
diff -ur dovecot-1.2.11.orig/src/imap/imap-expunge.c dovecot-1.2.11/src/imap/imap-expunge.c
--- dovecot-1.2.11.orig/src/imap/imap-expunge.c 2010-01-24 16:14:17.000000000 -0700
+++ dovecot-1.2.11/src/imap/imap-expunge.c      2010-06-03 09:15:21.496929714 -0600
@@ -5,7 +5,7 @@
 #include "mail-search-build.h"
 #include "imap-expunge.h"

-int imap_expunge(struct mailbox *box, struct mail_search_arg *next_search_arg)
+int imap_expunge(struct client *client, struct mailbox *box, struct mail_search_arg *next_search_arg)
 {
        struct mail_search_context *ctx;
         struct mailbox_transaction_context *t;
@@ -34,6 +34,7 @@
        while (mailbox_search_next(ctx, mail) > 0) {
                mail_expunge(mail);
                expunges = TRUE;
+               client->expunged++;
        }
        mail_free(&mail);

diff -ur dovecot-1.2.11.orig/src/imap/imap-expunge.h dovecot-1.2.11/src/imap/imap-expunge.h
--- dovecot-1.2.11.orig/src/imap/imap-expunge.h 2008-06-08 21:14:46.000000000 -0600
+++ dovecot-1.2.11/src/imap/imap-expunge.h      2010-06-03 09:15:54.336803693 -0600
@@ -3,6 +3,6 @@

 struct mail_search_arg;

-int imap_expunge(struct mailbox *box, struct mail_search_arg *next_search_arg);
+int imap_expunge(struct client *client, struct mailbox *box, struct mail_search_arg *next_search_arg);

 #endif
