[Rspamd-Users] bayes - dovecot/sieve question

Markus Schönhaber rspamd-community at list-post.ddt-consult.de
Tue Sep 26 06:20:51 UTC 2023


26.09.23, 01:27 +0200, Stanislav via Users:

> On 2023-09-25 12:45, Markus Schönhaber wrote:
>> 25.09.23, 20:40 +0200, Stanislav via Users:
>>
>>> I struggle to understand the configuration for dovecot/sieve trigger 
>>> learning spam/ham.
>>>
>>> I'm following this 3rd party manual: 
>>> https://www.c0ffee.net/blog/mail-server-guide
>>>
>>> So there are following components/files:
>>> =========== /usr/local/etc/dovecot/sieve/report-spam.sieve
>>> require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", 
>>> "variables"];
>>>
>>> if environment :matches "imap.email" "*" {
>>>    set "email" "${1}";
>>> }
>>>
>>> pipe :copy "train-spam.sh" [ "${email}" ];
>> [...]
>>> =========== /usr/local/etc/dovecot/sieve/train-spam.sh
>>> exec /usr/local/bin/rspamc -h /var/run/rspamd/rspamd.sock learn_spam
>> [...]
>>> Now, when I move a letter to junk to trigger it - I'm confused about 
>>> how exactly "rspamc learn_spam" knows what exact email needs to 
>>> learn. From what I see we pass an "email" only.
>>
>> The "pipe" sieve command passes the value of ${email} as a parameter 
>> to the script, while the the mail's content is piped to the script's 
>> standard input. Therefore, stdin is where your script (and in turn 
>> rspamc) gets the mail it is supposed to learn.
> 
> Ok, one more question :)
> What's the point of passing ${email} as a parameter to the script if 
> there's no "$1" defined in the script itself, so the script isn't using it.
> Is this for logging purpose or rspamc somehow gets this?

The above sieve script is probably supposed to work with other anti-spam 
solutions, where the respective command for spam/ham learning might 
*need* to be passed the recipient mail address somehow (most likely as a 
parameter).

In your particular example though, the script indeed doesn't pass the 
${email} parameter on to rspamc.
But you could add, for example, -r $1 or -d $1 to the script's call to 
rspamc if you'd like.

-- 
Regards
   mks


More information about the Users mailing list