Dovecot sieve filters

j.emerlik j.emerlik at gmail.com
Sun Sep 19 16:24:11 EEST 2021


I'm have a problem where dovecot-sieve is used to run the script after
moving emails from Junk Folder.

config:

imapsieve_mailbox2_name = *
Imapsieve_mailbox2_from = INBOX.Junk
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before =
file:/usr/local/lib/dovecot/sieve/report-ham.sieve

filter:

require [ "vnd.dovecot.pipe", "copy", "imapsieve", "environment",
"variables", "fileinto", "envelope" ];

if environment :matches "imap.mailbox" "*" {
  set "mailbox" "${1}";
}

if string "${mailbox}" "INBOX.Trash" {
  stop;
}

if environment :matches "imap.user" "*" {
  set "username" "${1}";
}

pipe :copy "sa-learn-ham.sh" [ "${username}" ]

It's working perfectly.

However, I have a problem after adding :

if envelope :is "from" "*" {
    set :lower "from" "${1}";
}

pipe :copy "sa-learn-ham.sh" [ "${username}", "${from}" ]

then appears error in log file:

Error: sieve: report-ham: line 1: the envelope extension cannot be used in
this context (needs access to message envelope)

Is possible to use envelope extension to get sender address after moving
message from Junk folder ?

Regards,
Jack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://dovecot.org/pipermail/dovecot/attachments/20210919/7a5121fc/attachment.html>


More information about the dovecot mailing list