Server-wide per-account email filter?

ChrisTNM

Member
Sep 24, 2013
17
0
51
cPanel Access Level
Root Administrator
Does anyone know if this is possible? I would like to deliver mail with specific keywords in the subject link to the "Junk" folder relative to the account. So if an email with the keyword "spam" in the subject is sent to [email protected] then it is automatically filtered into the INBOX/Junk folder. I can setup a filter to do this on every account manually, but I'm curious to know if this can be done at a server level. Any thoughts?

I did some searching and I am not the first to pose this question, but I do not want to simply nullify the message and I'm not sure how to sort it to be relative to the account it's being delivered to.
 

ChrisTNM

Member
Sep 24, 2013
17
0
51
cPanel Access Level
Root Administrator
Hello :)

You can find information on using a system-wide filter on the following thread:

System Level Filtering

Thank you.
Thanks! This is the direction I needed to get started but it only answers half my question.
Let's say I do this:

Code:
# Spam Subject
if
 $header_subject: contains "{Spam"
then
  # Save to "junk" folder?
  save "/dev/null" 660
endif
Instead of nul-routing the email, how can I save it to the folder relevant to the account it's being delivered to? I still want to deliver the email, but in this case I want to deliver it to a specific folder.

Is this possible?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
One way to learn how to write filter rules is to create an account level filter in cPanel similar to what you want to do in a system filter, and then view the rule directly in:

/etc/vfilters/$domain.com

This will help show you how to write a filter rule.

Thank you.
 

ChrisTNM

Member
Sep 24, 2013
17
0
51
cPanel Access Level
Root Administrator
Okay, so if I create a account level filter, then I get something like this:

Code:
#{Spam?}
if
$header_subject: contains "{Spam?}"
then
save "$home/mail/domain.com/user/.Junk/" 660
endif
How can I get the "domain.com/user" part dynamically so it goes into the correct users folder? This is the part I'm stuck on. Any assistance would really be appreciated. Is this even possible?

Is there documentation on this somewhere?

Edit:
Found this:
Code:
 save "$home/mail/$domain/$local_part/.Junk/" 660
Source: http://www.exim.org/exim-html-current/doc/html/spec_html/filter_ch-exim_filter_files.html#SEC19
Not sure if it's correct.
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
You may want to post to the Exim users mailing list for input from other users about potential alternatives for the filter you require.

Thank you.