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:
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" "*" { .. }
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" ?
Yes, it's plugin imap_sieve enabled for IMAP protocol.
There isn't no way to catch address "from" when moving messages between IMAP folders ?
"If address :is "from" "*" { .. } - I have same error.
niedz., 19 wrz 2021, 16:38 użytkownik Gedalya gedalya@gedalya.net napisał:
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" "*" { .. }
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):
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.
On 20/09/2021 09:05, j.emerlik wrote:
After I deleted "envelope" from the "require":
if address :is "from" "*" { set :lower "from" "${1}"; }
You need to use :matches rather than :is.
It returns: null Null? That doesn't make sense. It should return the empty string if you do stuff like this.
if header :matches "From" "*" { set "address" ": ${1}"; }
It returns address as: "some string"
mailto:example@example.org>
This is the full header value, which can contain more than a single address.
Regards,
Stephan.
pon., 20 wrz 2021 o 01:44 Gedalya
mailto:gedalya@gedalya.net> napisał(a): 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.
participants (4)
-
Gedalya
-
Håkon Alstadheim
-
j.emerlik
-
Stephan Bosch