MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator
I am scanning email for spam before it hits my cpanel servers, email found to be spam is tagged in the header with: X-Spam-Flag: YES. I would like to create a folder in all email accounts called Junk. And then make sure all email with that header value get delivered automatically into that folder. Would be even better to figure out a cron job to empty it every 30 days or so. I know SA already does something like this, but I am not going to be running SA on my cpanel servers. Any suggestions are appreciated. I 100% understand this isnt the norm and is something were going to code up. Note, I am using dovecot on my servers.
 
Last edited:

MACscr

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

Thanks for the response, but I am looking to create this in an automated fashion for all existing accounts and then of course make it default for new accounts that are created. I think I made that pretty clear. Doing it manually through the gui for each account just isnt going to work for a thousand email accounts.
 

MACscr

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

I am a developer and I have figured out how to automate the filter creation, but the default imap folder issue is a dovecot configuration question. The dovecot autocreate plugin does work this purpose, but its also been depreciated in 2.2 and while still working, throws warnings about it being depreciated and that we should use mail {auto}. Which i have no idea how to use with cpanel's implementation of dovecot 2.2. Here are the docs for creating default imap folders: MailboxSettings - Dovecot Wiki
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,911
2,234
363
cPanel Access Level
DataCenter Provider
Twitter
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. After making the custom modifications, you must run:

Code:
/scripts/builddovecotconf
Let us know if this method is not allowing you to make custom changes.

Thank you.
 

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator
Right, I have already made a custom main.local, but I am not sure what the layout should be for this particular setting when it relates to how the main.local is setup for cpanel. The example from the dovecot wiki shows:

Code:
namespace inbox {
  #prefix = INBOX. # the namespace prefix isn't added again to the mailbox names.
  # ...

  mailbox Trash {
    auto = no
    special_use = \Trash
  }
  mailbox Drafts {
    auto = no
    special_use = \Drafts
  }
  mailbox Sent {
    auto = subscribe # autocreate, autosubscribe
    special_use = \Sent
  }
  mailbox Spam {
    auto = create # autocreate, but don't autosubscribe
    special_use = \Junk
  }
  mailbox virtual/All { # if you have a virtual "All messages" mailbox 
    auto = no
    special_use = \All
  }
}
But in my case, the Junk folder should not be a child of the Inbox and it appears that cpanel things a bit differently. I am definitely open to suggestions. Thanks again for the help.
 

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator
I was overcomplicating things. I just needed to add the following in namespace { } before the last bracket:

Code:
  mailbox Junk {
    auto = subscribe # autocreate, autosubscribe
    special_use = \Junk
  }
 

FeeReD

Well-Known Member
Dec 1, 2005
63
0
156
Dovecot folder structure in cPanel

People at my work are use to using a default folder structure for their IMAP clients. We are moving away from a really expensive to the simple mail cPanel alternative.

I am hoping though that someone knows a way to change the namespace from the following:

Code:
Inbox
 --- Drafts
 --- Junk
 --- Sent
 --- Trash
to

Code:
Inbox
Drafts
Sent Items
Deleted Items
Junk Email
I'm not sure if what was posted will override any settings of the default config cPanel has set. Will this cause anything to go haywire? Also, do I create a separate namespace for each folder? And if I follow those instructions on that page, how do I assign the trash folder?

Cheers
 
Last edited: