Autodelete deleted Mails in ISPC3 and Dovecot

Discussion in 'Server Operation' started by admins, Mar 27, 2015.

  1. admins

    admins Member

    Hi all
    How could I delete automatically all deleted Mails which are older than 30days on a ubuntu Server with ISPC3 and Dovecot?
    Thx
    admins
     
  2. Turbanator

    Turbanator Member HowtoForge Supporter

    Here is what I do based on some old discussions.
    Code:
    #!/bin/sh
    # Time to wait before removing mails from the Junk folder (Default: 7 days) Set 0 to turn off.
    junk_max_hours=$((24*7))
    # Time to wait before removing mails from the Trash folder (Default: 30 days) Set 0 to turn off.
    trash_max_hours=$((24*30))
    for domain in /var/vmail/*
    do
      if [ -d "$domain" ]
      then
        for user in $domain/*
        do
          if [ "$junk_max_hours" -gt "0" ]
          then
            if [ -d "$user/.Junk" ]
            then
              tmpreaper -m $junk_max_hours $user/.Junk/{cur,new}
            fi
          fi
          if [ "$trash_max_hours" -gt "0" ]
          then
            if [ -d "$user/.Trash" ]
            then
              tmpreaper -m $trash_max_hours $user/.Trash/{cur,new}
            fi
          fi
        done
      fi
    done
    
     
    admins and DDArt like this.

Share This Page