Skip to main content

Auto-deletion of emails

Comments

23 comments

  • vanessa
    There is not, but it's not too hard to do. It's been asked on these forums many times though.
    0
  • cag8f
    Great I'll give that a read--thanks!
    0
  • cPanelMichael
    Hello :) Note that if you want the "Trash" email automatically deleted, you can browse to: "WHM Home " Service Configuration " Mailserver Configuration" There is an option titled "Auto Expunge Trash" if you are using Dovecot, or an option called "IMAP Empty Trash" if you are using Courier. Thank you.
    1
  • marcochiesi
    Does the "Auto Expunge Trash" option also act on the accounts spam folders?
    0
  • cPanelMichael
    You can edit the following file for local modifications to the Dovecot configuration: /var/cpanel/templates/dovecot2.2/main.local
    Note: You can copy this file from /var/cpanel/templates/dovecot2.2/main.default if it does not exist. The relevant section here is: [% IF expire_trash %] expire_dict = proxy::expire expire = Trash expire2 = "Deleted Messages" expire3 = "INBOX.Deleted Messages" expire4 = INBOX.Trash
    You can add additional mailbox names to this section (e.g. Junk). After making the custom modifications, you must run: /scripts/builddovecotconf
    Thank you.
    0
  • marcochiesi
    Hi Michael, thanks a lot for your reply, it was exactly what I was looking for.... unfortunately I was not able to let it work. As you suggested I made a copy of /var/cpanel/templates/dovecot2.2/main.default to /var/cpanel/templates/dovecot2.2/main.local and I made the following changes: [% IF expire_trash %] expire_dict = proxy::expire expire = Trash expire2 = "Deleted Messages" expire3 = "INBOX.Deleted Messages" expire4 = INBOX.Trash expire5 = Junk expire6 = Spam expire7 = spam expire8 = INBOX.Junk expire9 = INBOX.Spam expire10 = INBOX.spam [% END %]
    Then I run /scripts/builddovecotconf
    which had the following output info [builddovecotconf] 'local' template in use (/var/cpanel/templates/dovecot2.2/main.local)
    I suppose there's a cPanel nightly task that calls this procedure, but it did not delete old spam messages last night. I also tried to manually run /scripts/maintenance
    which had this in its log ... [20141002.091305] Processing: Cleaning up mailbox trash [20141002.091305] - Processing command `/usr/local/cpanel/scripts/dovecot_auto_expunge_trash` ...
    but spam messages are still there. By the way, inside the dovecot config file a comment says: # Expire plugin. Mails are expunged from mailboxes after being there the # configurable time. The first expiration date for each mailbox is stored in # a dictionary so it can be quickly determined which mailboxes contain # expired mails. The actual expunging is done in a nightly cronjob, which # you must set up: # dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool
    but if I try to run dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool
    I get Fatal: Unknown argument: --exec-mail
    I suppose it was for an old dovecot version. Any ideas?
    0
  • cPanelMichael
    Do you notice any output when running "/scripts/dovecot_maintenance" directly? Have you moved new email to the Trash or SPAM directories since making the change and has it passed the expire time? Thank you.
    0
  • marcochiesi
    The "/scripts/dovecot_auto_expunge_trash" gives no output, but your words made me think... Many old messages were recently moved to Trash/Spam folders. I thought they would have been deleted since they were pretty old, but it makes sense that the 30 days are counted starting from the date of deletion and not from the date of the message. So I suppose they will be deleted in a month or so. By the way, is there a way to get the deletion date of a message?
    0
  • cPanelMichael
    You could try finding the individual email via the command line and using the "stat" command to see when it was last accessed. Thank you.
    0
  • mcpacific
    I have been having problems with this myself. Under WHM " Service Configuration " Mailserver Configuration I have set Auto Expunge Trash [checked] and set Trash Expire Time to be 10. Also, my dovecot.conf file includes the following: expire_dict = proxy::expire expire = Trash expire2 = "Deleted Messages" expire3 = "INBOX.Deleted Messages" expire4 = INBOX.Trash expire5 = Junk expire6 = INBOX.Junk
    Yet, Trash and Junk never auto expunge. I ran the following script manually, however, and it cleaned one of my Trash folders on one email account (the Junk folder was NOT auto expunged): /scripts/dovecot_auto_expunge_trash
    Other than checking the setting in Mailserver Configuration, do I need to manually add a cron job? What do I do about the Junk folders? I'm using WHM 11.48.
    0
  • cPanelMichael
    Hello, Do you use the instructions from my earlier post when modifying the Dovecot configuration? Thank you.
    0
  • mcpacific
    Hello, Do you use the instructions from my earlier post when modifying the Dovecot configuration? Thank you.

    Yes, precisely.
    0
  • cPanelMichael
    Feel free to open a support ticket using the link in my signature so we can take a closer look. You can post the ticket number here so we can update this thread with the outcome. Thank you.
    0
  • Mckenzielaa
    Hi @cPanelMichael , I have followed the steps in an old thread to auto delete the spam messages that Spamassassin marks as spam and places in the Junk folder, the thread is at Auto-deletion of emails but they do not work. I created the copied the file /var/cpanel/templates/dovecot2.2/main.default to /var/cpanel/templates/dovecot2.2/mail.local I added the expire 4, 5 and 6 [% IF expire_trash %] expire_dict = proxy::expire expire = Trash expire2 = "Deleted Messages" expire3 = "INBOX.Deleted Messages" expire4 = INBOX.Trash expire5 = Junk expire6 = INBOX.Junk I then rebuilt the config, and get the 'local' template in use message (/scripts/builddovecotconf) but when I run dovecot --exec-mail ext /usr/libexec/dovecot/expire-tool command I get Fatal: Unknown argument: --exec-mail error. When I try running /scripts/dovecot_auto_expunge_trash directly I get a -bash: /scripts/dovecot_auto_expunge_trash: No such file or directory error. Did you ever manage to get this working as I see you asked for the other person who asked about this to submit a ticket but no update was made to the thread
    0
  • cPanelMichael
    Hello @Mckenzielaa, The functionality of the auto_expunge_trash script was merged into /scripts/dovecot_maintenance in cPanel & WHM version 58. Can you verify if running /scripts/dovecot_maintenance removes the messages that are older than what you've set for the Trash Expire Time value? Thank you.
    0
  • Mckenzielaa
    Hi Michael, Running /scripts/dovecot_maintenance does not clear the junk out. That command gives no output either.
    0
  • cPanelMichael
    Hello @Mckenzielaa, Can you open a support ticket so we can take a closer look at your system to see how you've configured Dovecot and to verify that it's not working as intended? You can post the ticket number here and I'll link this thread to it. Thank you.
    0
  • actihost
    Hello, it seems that now the Mailserver Configuration has an Auto Spunge Spam feature, BUT it seems that its not visible when Spamassassin its not active in exim. Is this a bug or its by design? We didn't use Spamassassin but a lot of customers move spam emails to that folder using another filter making a lot of wasted space in junk emails. Is there a way to activate this feature without Spamassassin active?
    0
  • cPRex Jurassic Moderator
    @actihost - can you let me know which specific SpamAssassin option you have to enable in order to see this? Once I know that I can do some additional testing on my end, but our documentation at Mailserver Configuration | cPanel & WHM Documentation doesn't currently mention that anything needs to be enabled for that tool to work.
    0
  • actihost
    @actihost - can you let me know which specific SpamAssassin option you have to enable in order to see this? Once I know that I can do some additional testing on my end, but our documentation at
    0
  • cPRex Jurassic Moderator
    Thanks for that information. i can reproduce this behavior in version 102, but I can't in 104, so it seems we've taken care of this in the version 104 update.
    0
  • actihost
    Thanks for that information. i can reproduce this behavior in version 102, but I can't in 104, so it seems we've taken care of this in the version 104 update.

    I see, i will wait for 104 then. Thanks!
    0
  • ebizindia
    I have developed a cron script that will delete all spam emails older than a given number of days. You can test it manually and then set up a cronjob. /usr/bin/find /home/cpanel_username/mail/domainname.com/username/.spam/cur/ -type f -mtime +10 -exec rm {} \; Example: /usr/bin/find /home/testdom/mail/testdom.com/arun/.spam/cur/ -type f -mtime +10 -exec rm {} \; The following will do this for all users in the given domain. /usr/bin/find /home/testdom/mail/testdom.com/*/.spam/cur/ -type f -mtime +10 -exec rm {} \; If you set up a cronjob like the following, it will run at 12 midnight (server time) and clear up spam emails older than 10 days.
    0

Please sign in to leave a comment.