hayridumanli

Member
Jan 11, 2014
23
2
3
cPanel Access Level
Root Administrator
Hi,

I have read a lot about e-mail filter in forum, but I couldn't find the correct answers for myself.

1) I created a lot of Email Filters for [email protected] (for an e-mail), it's mostly "Subject" " contains" "spam_word" = "Discard message"
And some "From" "contains" "[email protected]" = "Discard message"
And the filters are working, no problem.
First question is;
Where is that filter file, I read in the forum, but I couldn't find the file which has filters in it. I looked at /etc/vfilters/domain.com, but I cannot change to domain.com folder, it's somewhat restricted.

2) If I can find the file, I want to combine the filters with "or" s, then I can manually edit the file to add new spam words or spam mails. This will be the second question if I can find the filter filer.
 

hayridumanli

Member
Jan 11, 2014
23
2
3
cPanel Access Level
Root Administrator
Thank you for your reply. I had seen this thread, but it didn't work as below;

I go to /etc/vfilters/ folder and I can see the files in that folder, there are domain names (as written $domain), but when I try to edit the file, such as vi caffenotte.com, the file is empty, there is nothing in the file. So, the filters are not in this file I guess, that's why I am asking the filter file's directory.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463
Hello,

Are you browsing to the global /etc/ directory as root via SSH, or the account's /home/$username/etc/ directory while logged in via SSH as the account username?

Thank you.
 

hayridumanli

Member
Jan 11, 2014
23
2
3
cPanel Access Level
Root Administrator
OK, here is the answer I wanted, thank you.
I browsed /home/$username/etc/@domain/@mail and I see 3 files there; filter, filter.cache and filter.yaml
Now, which file I will edit?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463

hayridumanli

Member
Jan 11, 2014
23
2
3
cPanel Access Level
Root Administrator
Actually that UAPI functions you mentioned are so complicated than I can handle, all I want to ask is like that;
Let's go on with 2 example filters in filter.yaml file;

actions:
-
action: save
dest: /dev/null
enabled: 1
filtername: 10 SAATTE INGILIZCE EGITIM SETI
rules:
-
match: contains
opt: or
part: "$header_subject:"
val: 10 SAATTE INGILIZCE EGITIM SETI
unescaped: 1
-
actions:
-
action: save
dest: /dev/null
enabled: 1
filtername: 2017 Is ve Sektor
rules:
-
match: contains
opt: or
part: "$header_subject:"
val: 2017 Is ve Sektor
unescaped: 1

If I combine them like this;

actions:
-
action: save
dest: /dev/null
enabled: 1
filtername: All subject filters
rules:
-
match: contains
opt: or
part: "$header_subject:"
val: 10 SAATTE INGILIZCE EGITIM SETI
or
val: 2017 Is ve Sektor

unescaped: 1
-

Is it OK? So that I can combine all the filters with "or"s.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,245
463
If I combine them like this;

actions:
-
action: save
dest: /dev/null
enabled: 1
filtername: All subject filters
rules:
-
match: contains
opt: or
part: "$header_subject:"
val: 10 SAATTE INGILIZCE EGITIM SETI
or
val: 2017 Is ve Sektor

unescaped: 1

Hello,

No, that's not the correct format. The combined rules would instead look like this in the YAML file:

Code:
---
filter:
  -
    actions:
      -
        action: save
        dest: /dev/null
    enabled: 1
    filtername: All subject filters
    rules:
      -
        match: contains
        opt: or
        part: "$header_subject:"
        val: 10 SAATTE INGILIZCE EGITIM SETI
      -
        match: contains
        opt: or
        part: "$header_subject:"
        val: 2017 Is ve Sektor
    unescaped: 1
version: '2.2'
However, that said, manually editing the filter.yaml file is unsupported. It won't automatically update the other filter files, and could lead to the system overwriting the changes. Instead, you'd need to use the UAPI function referenced in my previous post, or the cPanel UI to make the changes.

Thank you.