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
On 9/19/21 21:24, j.emerlik wrote:
Error: sieve: report-ham: line 1: the envelope extension cannot be used in this context (needs access to message envelope)
My guess would be that the envelope is not available because this is sieve running in IMAP, not during delivery.
If the From: header is also good, maybe try if address :is "from" "*" { .. }
Den 19.09.2021 16:37, skrev Gedalya:
Sounds right. There /is/ no envelope in the on-disk copy of the mail. The "from" line at the very top of the mail is _usually_ tere, and is a copy of the envelope from, but it is not strictly defined to be anything in particular. I see you are trying to down-case the address-part of the from-line. Why not do that in the shell-script "sa-learn-ham.sh" ?
On 9/20/21 03:15, j.emerlik wrote:
"If address :is "from" "*" { .. } - I have same error.
Quote:
Error: sieve: report-ham: line 1: the envelope extension cannot be used in this context (needs access to message envelope)
It says "line 1", that's your "require" line. You need to remove "envelope" from the "require" line.
After I deleted "envelope" from the "require":
if address :is "from" "*" { set :lower "from" "${1}"; }
It returns: null
if header :matches "From" "*" { set "address" ": ${1}"; }
It returns address as: "some string" <example@example.org>
pon., 20 wrz 2021 o 01:44 Gedalya <gedalya@gedalya.net> napisał(a):
participants (4)
-
Gedalya
-
Håkon Alstadheim
-
j.emerlik
-
Stephan Bosch