Deleting old e-mail messages in ispconfig3

Discussion in 'Installation/Configuration' started by showe1966, Jan 8, 2020.

  1. showe1966

    showe1966 Member

    Ladies and gentlemen, boys and girls, I am using Ubuntu 16.04.6 LTS and Ispconfig3.

    I have just re-installed the software on my client PC. I now run Linux Mint 19.3. Wu-wu !
    Due to I must be some kind of a masochist, I am still using ximian evolution as a mail client.
    (I probably should go to Thunderbird).
    Anyways, after I re-installed everything on my client PC, I re-installed evolution, and re-imported all of the mail messages back into the same location in the file system, re-started evolution and (By a miracle), all my zillions of (fairly useless) e-mail messages , virtual folders etc are all still there.
    All well and good, you are thinking.
    But, when I tried to download new messages, the MTA seems to "start from zero" as it where, and tries to download over 200,000 incoming e-mails from my server. Which, I suppose are all the e-mails that have ever been received on the server for that mail account.

    So, my simple problem is: How do I delete all these old messages from the server ?
    Apart from anything else, they are occupying quite some space I suppose, and having all this old cr** on my server is simply not useful.
    I had a look for docs, but there is nothing.
    So, I have proceeded as follows:-
    -My server is using postfix and dovecot and (apparently) vmail, whatever that is.
    After some futile googling and then some blundering about in the file system of the server, I have determined that all the e-mail messages for the account user(at) will be in the following directory:-


    Unt, the directory structure is like ziss:

    drwx------ 2 vmail vmail 3350528 Jan 8 09:27 cur
    -rw------- 1 vmail vmail 724544 Jan 7 18:21 dovecot.index
    -rw------- 1 vmail vmail 28064076 Jan 8 11:39 dovecot.index.cache
    -rw------- 1 vmail vmail 13796 Jan 8 11:39 dovecot.index.log
    -rw------- 1 vmail vmail 32828 Jan 7 05:59 dovecot.index.log.2
    -rw------- 1 vmail vmail 2105000 Jan 8 11:39 dovecot-uidlist
    -rw------- 1 vmail vmail 8 Sep 6 2016 dovecot-uidvalidity
    -r--r--r-- 1 vmail vmail 0 Sep 6 2016 dovecot-uidvalidity.57ce936a
    drwx------ 2 vmail vmail 36864 Jan 8 11:53 new
    -rwxr--r-- 1 vmail vmail 23 Sep 23 13:11 subscriptions
    drwx------ 2 vmail vmail 4096 Jan 8 11:39 tmp

    I had a look in the files and the directory "cur" is just a list of all the e-mail messages, all stored in separate files with weird looking names (Due to they have to be unique names ....apparently)
    So, I "just" deleted all of this directory and contents doing the following command:-
    rm -vR cur
    Then, I made the directory again like wot is was before:-
    mkdir cur
    chmod 0700 cur
    chown vmail.vmail cur

    And, I rebooted the server, and tried to download my mail again and the problem has been pretty much resolved.
    NB there does seem to be a bit of weird behaviour on my local client MTA (Like it says I have 20,000 new messages when I don't. But, who cares as long as mail is working is what I say ).

    However, I have some tricky questions such as:-
    1. There are a bunch of other files in the Maildir, such as dovecot.index.cache
    This file, for example, seems to be a list of all the messages that were in the directory cur before i deleted all of them. Should i delete these files and re-create them again with the right permissions to clear everything out ?
    (NB: I am keen not to f**k up my mail server, if at all possible.).
    I read something about how dovcot is really clever and it re-creates all the files wot you need all by itself. So, what with being faint hearted , I was kind of hoping I didn't need to change anything else in the file system and , after a bit, the software would just clean up all the mis-matches between the files and the contents of the directory cur by itself ???
    Thanks to everyone in advance for their helpful input.
  2. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Try exiting evolution, killing all remaining processes related to evolution (there will be several), then remove ~/.cache/evolution/mail/*

    You can reindex with:
    doveadm index -A '*'
    I don't know that I've ever had problems with dovecot maintaining it's index, even when manually moving/removing mail files. I have had quota/usage get out of sync numerous times, and have at times run a recalculation from a monthly cronjob to address that:
    doveadm quota recalc -A
  3. showe1966

    showe1966 Member

    Thanks for your input. I just tried the command
    doveadm index -A '*'
    but it did not seem to immediately change the size of the file
    Maybe it needs a restart of something to take effect ?
    Anyway, I checked the size of the files in the other mail accounts which I worked on yesterday. Now, all the files have reduced down to a reasonable size which is "in agreement" with the new contents of the cur directories ( i.e. not much in them.).
    So, according to me, the way to get round the problem I was seeing is to remove all the files in the cur directory for each mail account in question.
    For just one mail account, removing the contents of the cur directory has freed up 20G of disk space.........
  4. Steini86

    Steini86 Active Member

    It is better to use the doveadm tools to mess with mails, then the data stays consistent and dovecot has an easier job. For example:
    doveadm expunge -u [email protected] mailbox INBOX SENTBEFORE 1-Jan-2020
    doveadm expunge -u [email protected] mailbox INBOX.Sent SENTBEFORE 1-Jan-2020
    doveadm purge -u [email protected]

Share This Page