imapd and count of deleted messages

Michael Menge michael.menge at zdv.uni-tuebingen.de
Mon Nov 12 05:56:25 EST 2018


Hi,


Quoting Sergey <a_s_y at sama.ru>:

> Hello
>
> Can I see number of deleted messages per IMAP sessions?
> This is useful when communicating with the user sometimes.
>
> For imap I can see only this:
>
> cyrus/imap[862231]: login: .... User logged in  
> SESSIONID=<cyrus-862231-1541832038-1-29129931007288367>
> cyrus/imap[862231]: USAGE .... user: 0.228965 sys: 0.244962
>
> And much more for pop:
>
> cyrus/pop3[19165]: .... User logged in  
> SESSIONID=<cyrus-19165-1540823180-1-15155256727332989489>
> cyrus/pop3[19165]: Expunged 160 messages from ....
> cyrus/pop3[19165]: USAGE .... user: 0.564000 sys: 0.516000
> cyrus/pop3[19165]: counts: retr=<160> top=<0> dele=<160>
>


Are you sure messages have been "Deleted" via IMAP EXPUNGE command?

To clarify this: Deleting mails is a 2 or 3 stage process depending on
your configuration.

1. the mails are marked as deleted.

    ===== Example from RFC 3501 =====

    C: A003 STORE 2:4 +FLAGS (\Deleted)
    S: * 2 FETCH (FLAGS (\Deleted \Seen))
    S: * 3 FETCH (FLAGS (\Deleted))
    S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen))
    S: A003 OK STORE completed

    ===================================

    This is normally not logged by cyrus but you can see the number of Messages
    with the Deleted Flag with

     mbexamine user/userID | grep "^  Deleted:"

The Client can still see these messages. Some Clients use this to allow the
user to "undelete" Mails other kopie/move the mails to a trash folder and
use the second step to remove the mails form the original folder.
You can try enable the "auditlog" option in your imapd.conf if you really
need to know this.

2.  the mails marked as deleted are removed form the mailbox with the  
expunge command.

     ==== Quoting RFC 3501 =========


     Example:    C: A202 EXPUNGE
                 S: * 3 EXPUNGE
                 S: * 3 EXPUNGE
                 S: * 5 EXPUNGE
                 S: * 8 EXPUNGE
                 S: A202 OK EXPUNGE completed

     Note: In this example, messages 3, 4, 7, and 11 had the
     \Deleted flag set.  See the description of the EXPUNGE
     response for further explanation.

     ===============================

     This is logged by cyrus in the same way you have seen for pop3  
But can happen
     multiple times in the same imap session.


3.  depending of your "expunge_mode" setting in imapd.conf the mails  
deleted in step 2
     are still on your disk and are deleted by cyr_expire at a later time.

     you can see and restore the mails that have been EXPUNGE by the client,
     but not deleted by cyr_expire with the "unexpung" command see man page
     for more details

     Deleting mails form disk by cyr_expire was logged for each  
mailbox in cyrus 2.3
     and 2.4 in cyrus 3.0 it is logged only once per cyr_expire run.
     restoring mails with unexpung is also logged by cyrus.

     unexpunge[363]: restored 1 expunged messages in mailbox 'user/userID'


Regarding POP3 the messages Deleted in the Session are marked as  
deleted and are expunged
automatically with the quit command by the client at the end of the session.



--------------------------------------------------------------------------------
M.Menge                                Tel.: (49) 7071/29-70316
Universität Tübingen                   Fax.: (49) 7071/29-5912
Zentrum für Datenverarbeitung          mail:  
michael.menge at zdv.uni-tuebingen.de
Wächterstraße 76
72074 Tübingen



More information about the Info-cyrus mailing list