How to log a Sieve match in Dovecot debug_log

Lukas lukas at email.it
Sat Jun 30 12:28:43 EEST 2018


Hi everybody!

I manage a mail server running Dovecot 2.2.21 with Pigeonhole 0.4.10. I successfully configured sieve and use it also to filter some spam messages. Here is one of the script I use to filter messages on the basis of prohibited words in message body.

As you can see, the last command writes to the log the action of this script.


-- the script begins ------------

   require ["fileinto", "imap4flags", "editheader", "body", "vnd.dovecot.debug"];

   if anyof (

        body :text :contains "crypto",
        body :text :contains "sex",
        body :text :contains "viagra"
        )
   {
     setflag "\\Seen";
     addheader :last "X-Sieve-Filtered" "blocked words in message body";
     fileinto "INBOX.Spam";
     debug_log "Body contains blocked word: <the matching word>";
   }

-- the script ends --------------


MY QUESTION: is there a way to have also the result of the match in that log message? I mean, is it possible to have that "<the matching word>" substituted with the exact word that matched one of the conditions (more or less the same way it is possible using Exim's System Filter)? I googled and searched a lot Dovecot documentation but wasn't able to find a definite YES or NO to this question.

Thanks a lot!



Lukas


More information about the dovecot mailing list