[Rspamd-Users] Question about custom rspamd rule

Gabriele Nencioni gabriele.nencioni at register.it
Tue Nov 10 15:43:00 UTC 2020


Hi all,
I'm trying to create a custom rule following the related documentation:
https://rspamd.com/doc/tutorials/writing_rules.html

The code is:
config['regexp']['MY_HEADER_FROM_RULE'] = {
    re = "(From=/.*some_pattern.*>/umxs{header})";
    score = 1.20,
    description = 'Test rule',
    group = 'headers',
}

So far so good, when a pattern matches against the header-from the
symbol is triggered:
...
Symbol: MY_HEADER_FROM_RULE (1.20)
...


My question is: how can I add the header-from information as option of a
result? I'd like to have something like:
...
Symbol: MY_HEADER_FROM_RULE (1.20)[Random1234.com <noreply at random1234.com>]
...

I have modified my rule as following:
config['regexp']['MY_HEADER_FROM_RULE'] = {
    re = "(From=/.*some_pattern.*>/umxs{header})";
    score = 1.20,
    description = 'Test rule',
    group = 'headers',
    functions = {
      function(task)
      local headerfrom = task:get_header('From')
      task:insert_result('MY_HEADER_FROM_RULE', 1, headerfrom)
    end,
    }
}


without success.


Can anyone help me? Any suggestions?

Thanks in adavance
--
Gabriele Nencioni


More information about the Users mailing list