[Rspamd-Users] custom mail info logging

Franta Hanzlík franta at hanzlici.cz
Sun Aug 6 17:34:14 UTC 2023


On Mon, 31 Jul 2023 02:20:22 +0200
Gerald Galster <list+rspamd at gcore.biz> wrote:

> > now I'm using milter-regex mail filter, which has one nice feature - 
> > a one-line log about mail in the form:
> > 
> > Jul  1 02:14:58 sms milter-regex[2478]: smtp.hog.cz [20.4.13.7]: ACCEPT, HELO: mail.hog.cz, FROM: <info at asodi.cz>, RCPT: <danusa at arici.cz>, From: =?utf-8?Q?Nan=C4=9B_do_pici?= <info at laoli.cz>, To: =?utf-8?Q?Dia_=C5=A0=C3=A1hl=C3=A1?= <danusa at arici.cz>, Subject: =?UTF-8?B?xb7DoWRuw6Egc2zDoXZh?=
> > 
> > [...]
> > My question: is it possible to have a similar output from RSPAMD?  
> 
> Yes, see https://rspamd.com/doc/configuration/logging.html#log-format
> 
> You can set log_format in local.d/logging.inc and if the listed variables are not sufficient you can write a lua script to extract more information from the task object.
> 
> Best regards,
> Gerald
> -- 

Hi Gerald, thanks for advice! (and I'm blind and stupid for not finding
it)

As mime_from/mime_rcpts? log variables logs only pure mail address and
there is no variable for Subject, I tried to use lua script.
Unfortunately I don't know anything about lua.
Now I have in /etc/rspamd/local.d/logging.inc something as:

log_format =<<EOD
...
$lua{
  return function(task)
    return ' From:' .. task:get_header('From') .. ' To: ' .. task:get_header('To') .. ' Cc:' .. task:get_header('Cc') .. ' Subj:' .. task:get_header('Subject')
  end
}
...
EOD

Which work - sometimes... Problem is, when some header item isn't present
in the mail - then nothing is logged, not even items that exist in the mail.
Why is that? What with this?
---
TIA, Franta Hanzlik


More information about the Users mailing list