public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
Deprecated lua function replaced, better tag handling when spam
509a804a
data/conf/rspamd/lua/rspamd.local.lua | 79 +++++++++++++++++++----------------
1 file changed, 42 insertions(+), 37 deletions(-)
Diff
diff --git a/data/conf/rspamd/lua/rspamd.local.lua b/data/conf/rspamd/lua/rspamd.local.lua
index 236734f2..60516991 100644
--- a/data/conf/rspamd/lua/rspamd.local.lua
+++ b/data/conf/rspamd/lua/rspamd.local.lua
@@ -23,51 +23,56 @@ auth_domain_map = rspamd_config:add_map({
description = 'Map of domains we are authoritative for'
})
-rspamd_config:register_post_filter(function(task)
- local util = require("rspamd_util")
- local rspamd_logger = require "rspamd_logger"
+rspamd_config:register_symbol({
+ name = 'TAG_MOO',
+ type = 'postfilter',
+ callback = function(task)
+ local util = require("rspamd_util")
+ local rspamd_logger = require "rspamd_logger"
- local tagged_rcpt = task:get_symbol("TAGGED_RCPT")
- local user = task:get_recipients(0)[1]['user']
- local domain = task:get_recipients(0)[1]['domain']
- local rcpt = user .. '@' .. domain
- local authdomain = auth_domain_map:get_key(domain)
+ local tagged_rcpt = task:get_symbol("TAGGED_RCPT")
+ local user = task:get_recipients(0)[1]['user']
+ local domain = task:get_recipients(0)[1]['domain']
+ local rcpt = user .. '@' .. domain
+ local authdomain = auth_domain_map:get_key(domain)
- if tagged_rcpt then
- local tag = tagged_rcpt[1].options[1]
- rspamd_logger.infox("found tag: %s", tag)
- local action = task:get_metric_action('default')
- rspamd_logger.infox("metric action now: %s", action)
+ if tagged_rcpt then
+ local tag = tagged_rcpt[1].options[1]
+ rspamd_logger.infox("found tag: %s", tag)
+ local action = task:get_metric_action('default')
+ rspamd_logger.infox("metric action now: %s", action)
- if action ~= 'no action' and action ~= 'greylist' then
- rspamd_logger.infox("skipping tag handler for action: %s", action)
- return false
- end
+ if action ~= 'no action' and action ~= 'greylist' then
+ rspamd_logger.infox("skipping tag handler for action: %s", action)
+ task:set_metric_action('default', action)
+ end
- if authdomain then
- rspamd_logger.infox("found mailcow domain %s", domain)
- rspamd_logger.infox("querying tag settings for user %s", rcpt)
+ if authdomain then
+ rspamd_logger.infox("found mailcow domain %s", domain)
+ rspamd_logger.infox("querying tag settings for user %s", rcpt)
- if modify_subject_map:get_key(rcpt) then
- rspamd_logger.infox("user wants subject modified for tagged mail")
- local sbj = task:get_header('Subject')
- new_sbj = '=?UTF-8?B?' .. tostring(util.encode_base64('[' .. tag .. '] ' .. sbj)) .. '?='
- task:set_rmilter_reply({
- remove_headers = {['Subject'] = 1},
- add_headers = {['Subject'] = new_sbj}
- })
+ if modify_subject_map:get_key(rcpt) then
+ rspamd_logger.infox("user wants subject modified for tagged mail")
+ local sbj = task:get_header('Subject')
+ new_sbj = '=?UTF-8?B?' .. tostring(util.encode_base64('[' .. tag .. '] ' .. sbj)) .. '?='
+ task:set_rmilter_reply({
+ remove_headers = {['Subject'] = 1},
+ add_headers = {['Subject'] = new_sbj}
+ })
+ else
+ rspamd_logger.infox("Add X-Moo-Tag header")
+ task:set_rmilter_reply({
+ add_headers = {['X-Moo-Tag'] = 'YES'}
+ })
+ end
else
- rspamd_logger.infox("Add X-Moo-Tag header")
- task:set_rmilter_reply({
- add_headers = {['X-Moo-Tag'] = 'YES'}
- })
+ rspamd_logger.infox("skip delimiter handling for unknown domain")
end
- else
- rspamd_logger.infox("skip delimiter handling for unknown domain")
+ return false
end
- return false
- end
-end)
+ end,
+ priority = 10
+})
rspamd_config.MRAPTOR = {
callback = function(task)