mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2024-09-20 07:16:18 +08:00
Updated spamfilter rules
This commit is contained in:
parent
3a5ca70365
commit
89433f3f06
|
@ -45,7 +45,8 @@ script_names = {
|
||||||
"greylist" : "Greylisting"
|
"greylist" : "Greylisting"
|
||||||
}
|
}
|
||||||
|
|
||||||
maps = ["scores.map",
|
maps = ["spam_config.map",
|
||||||
|
"scores.map",
|
||||||
"allow_dmarc.list",
|
"allow_dmarc.list",
|
||||||
"allow_domains.list",
|
"allow_domains.list",
|
||||||
"allow_spf_dkim.list",
|
"allow_spf_dkim.list",
|
||||||
|
@ -68,7 +69,7 @@ def read_file(file):
|
||||||
return f.read() + "\n"
|
return f.read() + "\n"
|
||||||
|
|
||||||
def build_spam_filters(scripts):
|
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():
|
for script_name, file_list in scripts.items():
|
||||||
script_content = read_and_concatenate(file_list).replace("'''", "\\'\\'\\'")
|
script_content = read_and_concatenate(file_list).replace("'''", "\\'\\'\\'")
|
||||||
script_description = script_names[script_name]
|
script_description = script_names[script_name]
|
||||||
|
@ -85,9 +86,6 @@ def main():
|
||||||
spam_filter = build_spam_filters(scripts)
|
spam_filter = build_spam_filters(scripts)
|
||||||
with open("spamfilter.toml", "w", encoding="utf-8") as toml_file:
|
with open("spamfilter.toml", "w", encoding="utf-8") as toml_file:
|
||||||
toml_file.write(spam_filter)
|
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.")
|
print("Stalwart TOML configuration files have been generated.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -49,13 +49,6 @@ compression = "lz4"
|
||||||
type = "internal"
|
type = "internal"
|
||||||
store = "rocksdb"
|
store = "rocksdb"
|
||||||
|
|
||||||
[lookup.default]
|
|
||||||
domain = "%{env:DOMAIN}%"
|
|
||||||
hostname = "%{env:HOSTNAME}%"
|
|
||||||
|
|
||||||
[oauth]
|
|
||||||
key = "%{env:OAUTH_KEY}%"
|
|
||||||
|
|
||||||
[tracer."stdout"]
|
[tracer."stdout"]
|
||||||
type = "stdout"
|
type = "stdout"
|
||||||
level = "info"
|
level = "info"
|
||||||
|
@ -66,7 +59,6 @@ enable = true
|
||||||
#user = "stalwart-mail"
|
#user = "stalwart-mail"
|
||||||
#group = "stalwart-mail"
|
#group = "stalwart-mail"
|
||||||
|
|
||||||
[server.http]
|
[authentication.fallback-admin]
|
||||||
headers = ["Access-Control-Allow-Origin: *",
|
user = "admin"
|
||||||
"Access-Control-Allow-Methods: POST, GET, PATCH, PUT, DELETE, HEAD, OPTIONS",
|
secret = "%{env:ADMIN_SECRET}%"
|
||||||
"Access-Control-Allow-Headers: Authorization, Content-Type, Accept, X-Requested-With"]
|
|
|
@ -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]
|
[version]
|
||||||
is-spam = "X-Spam-Status: Yes"
|
spam-filter = "1.0"
|
||||||
|
|
||||||
[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'" } ]
|
|
||||||
|
|
||||||
[sieve.trusted.scripts.spam-filter]
|
[sieve.trusted.scripts.spam-filter]
|
||||||
name = "Spam Filter"
|
name = "Spam Filter"
|
||||||
|
@ -2464,6 +2446,21 @@ if eval "!key_exists(SPAM_DB, triplet)" {
|
||||||
|
|
||||||
|
|
||||||
[lookup]
|
[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",
|
spam-scores = {"ABUSE_SURBL" = "5.0",
|
||||||
"ALLOWLIST_DKIM" = "-1.0",
|
"ALLOWLIST_DKIM" = "-1.0",
|
||||||
"ALLOWLIST_DMARC" = "-7.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