Expunge Specific IMAP Folder?

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator
I need to expunge emails that have been sitting in users Junk mail folders every X number of days. I see where I can setup a main.local for dovecot and use:

Code:
  expire5 = Junk
  expire6 = INBOX.Junk
But I am not sure how to actually set the numbers of days. The other option is typically to do:

Code:
/usr/bin/doveadm expunge -A mailbox Trash savedbefore 27d
but its returning:

Code:
doveadm(root): Error: User listing returned failure
I am open to ideas. Note, I am not using SA on my cpanel servers.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello :)

Could you let us know which version of cPanel is installed on your system? cPanel version 11.40 includes Dovecot 2.2 and native support to automatically expunge the Trash directory. It's configured in:

"WHM Home » Service Configuration » Mailserver Configuration"

Note that cPanel version 11.40 is currently only available in the "Current" and "Edge" build tiers.

Thank you.
 

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator
Michael,

yes, I am running 11.40, but if you read my question, I am trying to do another expunge a folder OTHER than Trash. The code example was just an example.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
You can edit the following file for local modifications to the Dovecot configuration:

Code:
/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:

Code:
[% 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:

Code:
/scripts/builddovecotconf
Thank you.
 

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator
yeah, i was thinking of that method as well, but wasnt sure how I could control how often the Junk folder would be expired. needs to be a bit more often than the Trash.