Regenerating Account Level Filters after Manually Editing /etc/vfilters

grantcooper

Registered
Jan 19, 2013
2
0
1
cPanel Access Level
Website Owner
I have reviewed various (old) threads here but do not see any answer to my following question.

When creating email account level filters in cPanel (11.32) it appears to create 2 files ;

/etc/vfilters/domain.com and

~/.cpanel/filter.yaml

If I attempt to edit directly the filter rules in /etc/vfilters/domain.com it says to edit the .yaml file.

If I do manually edit the .yaml file what cPanel script would regenerate the /etc/vfilter/domain.com file so the filters all correctly work.

Or does the regeneration occur automatically??

Thank you
 

grantcooper

Registered
Jan 19, 2013
2
0
1
cPanel Access Level
Website Owner
For anyone else experiencing this issue I found a way to get it to work.

Manually edit the ~/.cpanel/filter.yaml file, adding new rules and actions. Ensure of course to maintain correct syntax.

Remove the filter cache file at ~/.cpanel/filter.cache

Re-Login to cPanel for that user and navigate to Email -> Account Level Filters section. You will now see all changes made to the ~/.cpanel/filter.yaml file reflected in the cPanel interface.

At this point there have been no changes made in the /etc/vfilters files however.

You could manually edit the /etc/vfilters file, but what I found was easier was to simply add a dummy filter in the cPanel interface.

Save that record and cPanel will add it to the ~/.cpanel/filter.yaml file AND update the /etc/vfilters file with this new dummy filter and all previous manual edits to the filter.yaml file.

I am sure if I straced the cPanel server process I could identify the script that updates the /etc/vfilters file, but this simple method served my purposes for right now.

I hope this may be of some help to someone else.
 

rezman

Well-Known Member
Feb 3, 2011
45
0
56
USA
cPanel Access Level
Root Administrator
I'm currently working on making a way to auto-create a default user level filter for all new email accounts created. Everything works in my scripts however I don't know how to generate the "filter.cache" file. There has to be a way to run something via command line to do this. After all Cpanel is running a perl script to do this after you save a new filter via the web interface.


If you're asking "Why is he doing this?" well here is why.

Cpanel doesn't support per email box whitelist. Right now our users need to call us and say "add [email protected] to the white list as it keeps getting marked as spam and sent to my spam folder."

I'm going to create default filters to reproduce this system on a per-mailbox basis. Here is my default filter for any new email box. I just can't create/rebuild the "filter.cache" file without going into the web interface.

Code:
#White List
if
 $header_from: is "[email protected]"
 or $header_from: ends "@OURDOMAN.net"
then
 save "$home/mail/OURDOMAN.net/BOXNAME/" 660
endif

#Black List
if
 $header_from: is "[email protected]"
then
 save "$home/mail/OURDOMAN.net/BOXNAME/.spam/" 660
endif

#Deliver SPAM to Spam Folder
if
 $h_X-Spam-Bar: contains "+++++"
then
 save "$home/mail/OURDOMAN.net/BOXNAME/.spam/" 660
endif
This creates 3 filters.
Filter: White List
Filter: Black List
Filter: Deliver SPAM to Spam Folder

The owner can then add to the "Whitelist" or "Blacklist" filters if they wish. They can also adjust the 3rd filter to chose what spam level they want sent to the spam folder or turn it off altogether.
 

cPanelPeter

Technical Analyst III
Staff member
Sep 23, 2013
575
20
143
cPanel Access Level
Root Administrator
Twitter
Hello,

Not sure where you got the idea that cPanel doesn't support per mailbox white listing. There are per mailbox filters for every email account and you can set them up to deliver to the INBOX if a certain FROM address is found.
 

rezman

Well-Known Member
Feb 3, 2011
45
0
56
USA
cPanel Access Level
Root Administrator
Hello,

Not sure where you got the idea that cPanel doesn't support per mailbox white listing. There are per mailbox filters for every email account and you can set them up to deliver to the INBOX if a certain FROM address is found.
I have the SpamBox enabled for the account to deliver mail to the spam box. If I put my gmail from address in a filter rule for my test mailbox to deliver to the inbox on this account and send a GTUBE test email. It gets marked as spam and dropped in the spam folder when it should be dropped in the inbox no matter what happens.

The only way to add to the whitelist is to go into the Cpanel account under SpamAssassin > Configure Apache SpamAssassin and add to the whitelist.

Another reason I want to change it to my method is it gives each mailbox owner control on what spam score they want delivered to their spam folder. Right now I'm using 5. If they want say, 8 or higher dropped in their spam folder then they can adjust the spam-bar filter rule. They could delete this rule as well which would simulate turning off spam checking for their mailbox.

BTW I figured out how I can do this over the weekend. I'll just have to use the API to create the default rules for all newly created mailboxes. This will create/rebuild the .cache file. This will work fine and most likely be a better way to do this in the end.
 

normcdn

Registered
Oct 11, 2014
1
0
1
cPanel Access Level
Website Owner
Any clue on how to generate « filter.cache » from « filter.yaml » ?
I manually edit filter.yaml and it works fine for me but using notepad2 to create my list, but I am still stuck to login in the account level filtering for the system to create filter.cache.
A command line to create filter.cache would be great!
Any help would be really appreciated.
I had no choice to do this. I get about 300 junks everyday PER account. It is a disease for the internet :-(