mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-02-25 00:12:58 +08:00
Updated spamfilter rules
This commit is contained in:
parent
3a5ca70365
commit
89433f3f06
6 changed files with 37 additions and 75 deletions
|
@ -45,7 +45,8 @@ script_names = {
|
|||
"greylist" : "Greylisting"
|
||||
}
|
||||
|
||||
maps = ["scores.map",
|
||||
maps = ["spam_config.map",
|
||||
"scores.map",
|
||||
"allow_dmarc.list",
|
||||
"allow_domains.list",
|
||||
"allow_spf_dkim.list",
|
||||
|
@ -68,7 +69,7 @@ def read_file(file):
|
|||
return f.read() + "\n"
|
||||
|
||||
def build_spam_filters(scripts):
|
||||
spam_filter = read_file("./spamfilter/settings.toml")
|
||||
spam_filter = "[version]\nspam-filter = \"1.0\"\n\n"
|
||||
for script_name, file_list in scripts.items():
|
||||
script_content = read_and_concatenate(file_list).replace("'''", "\\'\\'\\'")
|
||||
script_description = script_names[script_name]
|
||||
|
@ -85,9 +86,6 @@ def main():
|
|||
spam_filter = build_spam_filters(scripts)
|
||||
with open("spamfilter.toml", "w", encoding="utf-8") as toml_file:
|
||||
toml_file.write(spam_filter)
|
||||
config = read_file("./minimal.toml") + read_file("./security.toml") + spam_filter
|
||||
with open("config.toml", "w", encoding="utf-8") as toml_file:
|
||||
toml_file.write(config)
|
||||
print("Stalwart TOML configuration files have been generated.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -49,13 +49,6 @@ compression = "lz4"
|
|||
type = "internal"
|
||||
store = "rocksdb"
|
||||
|
||||
[lookup.default]
|
||||
domain = "%{env:DOMAIN}%"
|
||||
hostname = "%{env:HOSTNAME}%"
|
||||
|
||||
[oauth]
|
||||
key = "%{env:OAUTH_KEY}%"
|
||||
|
||||
[tracer."stdout"]
|
||||
type = "stdout"
|
||||
level = "info"
|
||||
|
@ -66,7 +59,6 @@ enable = true
|
|||
#user = "stalwart-mail"
|
||||
#group = "stalwart-mail"
|
||||
|
||||
[server.http]
|
||||
headers = ["Access-Control-Allow-Origin: *",
|
||||
"Access-Control-Allow-Methods: POST, GET, PATCH, PUT, DELETE, HEAD, OPTIONS",
|
||||
"Access-Control-Allow-Headers: Authorization, Content-Type, Accept, X-Requested-With"]
|
||||
[authentication.fallback-admin]
|
||||
user = "admin"
|
||||
secret = "%{env:ADMIN_SECRET}%"
|
|
@ -1,19 +0,0 @@
|
|||
[queue.quota.queue-max-size]
|
||||
messages = 100000
|
||||
size = 10737418240 # 10gb
|
||||
enable = true
|
||||
|
||||
[queue.throttle.recipient-limit]
|
||||
key = ["rcpt_domain"]
|
||||
concurrency = 5
|
||||
enable = true
|
||||
|
||||
[session.throttle.concurrency-by-remote-ip]
|
||||
key = ["remote_ip"]
|
||||
concurrency = 5
|
||||
enable = true
|
||||
|
||||
[session.throttle.rate-by-sender]
|
||||
key = ["sender_domain", "rcpt"]
|
||||
rate = "25/1h"
|
||||
enable = true
|
|
@ -1,23 +1,5 @@
|
|||
[spam.header]
|
||||
is-spam = "X-Spam-Status: Yes"
|
||||
|
||||
[lookup.spam-config]
|
||||
add-spam = true
|
||||
add-spam-result = true
|
||||
learn-enable = true
|
||||
learn-balance = "0.9"
|
||||
learn-ham-replies = true
|
||||
learn-ham-threshold = "-0.5"
|
||||
learn-spam-threshold = "6.0"
|
||||
threshold-spam = "5.0"
|
||||
threshold-discard = "0.0"
|
||||
threshold-reject = "0.0"
|
||||
directory = ""
|
||||
lookup = ""
|
||||
|
||||
[session.data]
|
||||
script = [ { if = "is_empty(authenticated_as)", then = "'spam-filter'"},
|
||||
{ else = "'track-replies'" } ]
|
||||
[version]
|
||||
spam-filter = "1.0"
|
||||
|
||||
[sieve.trusted.scripts.spam-filter]
|
||||
name = "Spam Filter"
|
||||
|
@ -2464,6 +2446,21 @@ if eval "!key_exists(SPAM_DB, triplet)" {
|
|||
|
||||
|
||||
[lookup]
|
||||
spam-config = {
|
||||
"add-spam" = true,
|
||||
"add-spam-result" = true,
|
||||
"learn-enable" = true,
|
||||
"learn-balance" = "0.9",
|
||||
"learn-ham-replies" = true,
|
||||
"learn-ham-threshold" = "-0.5",
|
||||
"learn-spam-threshold" = "6.0",
|
||||
"threshold-spam" = "5.0",
|
||||
"threshold-discard" = "0.0",
|
||||
"threshold-reject" = "0.0",
|
||||
"directory" = "",
|
||||
"lookup" = ""
|
||||
}
|
||||
|
||||
spam-scores = {"ABUSE_SURBL" = "5.0",
|
||||
"ALLOWLIST_DKIM" = "-1.0",
|
||||
"ALLOWLIST_DMARC" = "-7.0",
|
||||
|
|
14
resources/config/spamfilter/maps/spam_config.map
Normal file
14
resources/config/spamfilter/maps/spam_config.map
Normal file
|
@ -0,0 +1,14 @@
|
|||
spam-config = {
|
||||
"add-spam" = true,
|
||||
"add-spam-result" = true,
|
||||
"learn-enable" = true,
|
||||
"learn-balance" = "0.9",
|
||||
"learn-ham-replies" = true,
|
||||
"learn-ham-threshold" = "-0.5",
|
||||
"learn-spam-threshold" = "6.0",
|
||||
"threshold-spam" = "5.0",
|
||||
"threshold-discard" = "0.0",
|
||||
"threshold-reject" = "0.0",
|
||||
"directory" = "",
|
||||
"lookup" = ""
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
[spam.header]
|
||||
is-spam = "X-Spam-Status: Yes"
|
||||
|
||||
[lookup.spam-config]
|
||||
add-spam = true
|
||||
add-spam-result = true
|
||||
learn-enable = true
|
||||
learn-balance = "0.9"
|
||||
learn-ham-replies = true
|
||||
learn-ham-threshold = "-0.5"
|
||||
learn-spam-threshold = "6.0"
|
||||
threshold-spam = "5.0"
|
||||
threshold-discard = "0.0"
|
||||
threshold-reject = "0.0"
|
||||
directory = ""
|
||||
lookup = ""
|
||||
|
||||
[session.data]
|
||||
script = [ { if = "is_empty(authenticated_as)", then = "'spam-filter'"},
|
||||
{ else = "'track-replies'" } ]
|
Loading…
Reference in a new issue