executing script on mail arrival from sieve
@lbutlr
kremels at kreme.com
Thu Jun 11 20:53:46 EEST 2020
On 11 Jun 2020, at 05:24, Voytek Eymont <voytek at sbt.net.au> wrote:
>
> looking at wiki2, 'Pigeonhole Sieve Extprograms Plugin', is this what
> would allow to execute my script on new mail arrival?
Yes.
This is what I have to auto=mark spam when it is moved too the Spam folder and to mark messages as seen when they are archived:
plugin {
sieve_plugins = sieve_imapsieve sieve_extprograms
#sieve_global = /usr/lib/dovecot/sieve/global/
sieve_default = /usr/lib/dovecot/sieve/default.sieve
sieve_default_name = spamassassin
sieve_duplicate_default_period = 1h
sieve_duplicate_max_period = 12d
# From elsewhere to Spam folder
imapsieve_mailbox1_name = Junk
imapsieve_mailbox1_causes = COPY
imapsieve_mailbox1_before = file:/usr/lib/dovecot/sieve/report-spam.sieve
# From Spam folder to elsewhere
imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Junk
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve
sieve_pipe_bin_dir = /usr/lib/dovecot/sieve
sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
sieve_extensions = +editheader
sieve = file:~/.sieve;active=~/.active_sieve
sieve_user_log = ~/sieve.log
imapsieve_mailbox3_name = Archive
imapsieve_mailbox3_causes = COPY
imapsieve_mailbox3_before = file:/usr/lib/dovecot/sieve/mark-read.sieve
}
# cat /usr/lib/dovecot/sieve/report-spam.sieve [11:51] [/etc/dovecot]
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "sa-learn-spam.sh" [ "${username}" ];
"sa-learn-spam.sh" is the name of the script:
# cat /usr/lib/dovecot/sieve/sa-learn-spam.sh
#!/bin/sh
exec /usr/local/bin/sa-learn -u ${1} --spam
# cat /usr/lib/dovecot/sieve/mark-read.sieve
require ["imap4flags"];
setflag "\\seen";
--
If you write the word "monkey" a million times, do you start to think
you're Shakespeare? -- Steven Wright
More information about the dovecot
mailing list