How do I make "vnd.dovecot.environment" available?
Hi all,
According to the docs at https://wiki.dovecot.org/Pigeonhole/Sieve, some extensions are not available by default.
The docs tell me the sieve_plugins, sieve_extensions and/or sieve_global_extensions configs are involved, but I can find no authoritative documentation as to what the values should be.
What values must I use to make “vnd.dovecot.environment” available?
Adding "sieve_global_extensions = +vnd.dovecot.environment” to 90-sieve.conf seems to not be enough.
[root@gatekeeper ~]# sievec -D /var/lib/dovecot-sieve/default.sieve
sievec(root): Debug: sieve: Pigeonhole version 0.5.8 (b7b03ba2) initializing
sievec(root): Debug: sieve: include: sieve_global is not set; it is currently not possible to include :global' scripts. sievec(root): Debug: sieve: file storage: Using Sieve script path: /var/lib/dovecot-sieve/default.sieve sievec(root): Debug: sieve: file script: Opened script
default' from /var/lib/dovecot-sieve/default.sieve' default: line 5: error: require command: unknown Sieve capability
vnd.dovecot.environment'.
default: line 19: error: referring to variable in unknown namespace 'vnd'.
default: error: validation failed.
sievec(root): Fatal: failed to compile sieve script '/var/lib/dovecot-sieve/default.sieve'
Regards, Graham —
On 24. Sep 2020, at 18.58, Graham Leggett minfrin@sharp.fm wrote:
Hi all,
According to the docs at https://wiki.dovecot.org/Pigeonhole/Sieve, some extensions are not available by default.
The docs tell me the sieve_plugins, sieve_extensions and/or sieve_global_extensions configs are involved, but I can find no authoritative documentation as to what the values should be.
What values must I use to make “vnd.dovecot.environment” available?
Adding "sieve_global_extensions = +vnd.dovecot.environment” to 90-sieve.conf seems to not be enough.
[root@gatekeeper ~]# sievec -D /var/lib/dovecot-sieve/default.sieve sievec(root): Debug: sieve: Pigeonhole version 0.5.8 (b7b03ba2) initializing sievec(root): Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts. sievec(root): Debug: sieve: file storage: Using Sieve script path: /var/lib/dovecot-sieve/default.sieve sievec(root): Debug: sieve: file script: Opened script
default' from/var/lib/dovecot-sieve/default.sieve' default: line 5: error: require command: unknown Sieve capability
vnd.dovecot.environment'. default: line 19: error: referring to variable in unknown namespace 'vnd'. default: error: validation failed. sievec(root): Fatal: failed to compile sieve script '/var/lib/dovecot-sieve/default.sieve'
can you link your doveconf -n and the sieve script?
Sami
On 24 Sep 2020, at 20:45, Sami Ketola sami.ketola@dovecot.fi wrote:
can you link your doveconf -n and the sieve script?
The user’s detail are:
[root@gatekeeper ~]# doveadm user minfrin@example.com field value uid vmail gid vmail home /home/vmail/minfrin@example.com/ mail maildir:~/mail mail_auto_reply_mode reply mail_auto_reply_text I am truly away...
The sieve script is:
[root@gatekeeper ~]# cat /var/lib/dovecot-sieve/default.sieve #
require ["fileinto", "mailbox"]; require ["vacation", "variables"]; require ["vnd.dovecot.environment"];
# fileinto: for putting mail into a imap folder # mailbox: for creating imap folder if not exists # if header :contains "X-Spam-Flag" "YES" { # move mail into folder Junk, create folder if not exists fileinto :create "Junk"; stop; }
#if string :matches "${vnd.dovecot.mail_auto_reply_mode}" "reply" { if header :matches "subject" "*" { vacation :subject "AutoReply: ${1}" "${vnd.dovecot.mail_auto_reply_text}"; } #}
The dovecot -n is:
[root@gatekeeper ~]# dovecot -n
# 2.3.8 (9df20d2db): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.8 (b7b03ba2)
# OS: Linux 4.18.0-193.19.1.el8_2.x86_64 x86_64 CentOS Linux release 8.2.2004 (Core)
# Hostname: gatekeeper.horizonmarine.co.za
first_valid_uid = 201
mail_gid = vmail
mail_location = maildir:~/mail
mail_plugins = acl
mail_uid = vmail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext
mbox_write_locks = fcntl
namespace {
list = children
location = maildir:%%h/mail:INDEXPVT=~/shared/%%u
prefix = Shared/%%u/
separator = /
subscriptions = yes
type = shared
}
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
special_use = \Trash
}
prefix =
separator = /
type = private
}
passdb {
args = /etc/dovecot/dovecot-ldap.conf.ext
driver = ldap
}
plugin {
sieve = file:~/sieve;active=~/.dovecot.sieve
sieve_default = /var/lib/dovecot-sieve/default.sieve
sieve_global_extensions = +vnd.dovecot.environment
sieve_plugins = sieve_extprograms
}
protocols = lmtp imap pop3 submission
service imap-login {
inet_listener imap {
address = 127.0.0.1, ::1
}
inet_listener imaps {
port = 993
ssl = yes
}
}
service imap {
vsz_limit = 1 G
}
service pop3-login {
inet_listener pop3 {
address = 127.0.0.1, ::1
}
inet_listener pop3s {
port = 995
ssl = yes
}
}
service submission-login {
inet_listener submission {
port = 587
}
inet_listener submissions {
haproxy = no
port = 465
reuse_port = no
ssl = yes
}
}
ssl = required
ssl_cert =
The sieve test is:
sieve-test(root): Debug: sieve: Pigeonhole version 0.5.8 (b7b03ba2) initializing
sieve-test(root): Debug: sieve: include: sieve_global is not set; it is currently not possible to include :global' scripts. sieve-test(root): Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.5.8 (b7b03ba2) loaded debug: file storage: Using Sieve script path: /var/lib/dovecot-sieve/default.sieve. debug: file script: Opened script
default' from `/var/lib/dovecot-sieve/default.sieve'.
debug: Script binary /var/lib/dovecot-sieve/default.svbin successfully loaded.
debug: binary save: not saving binary /var/lib/dovecot-sieve/default.svbin, because it is already stored.
Performed actions:
- send vacation message: => seconds : 604800 => subject : AutoReply: Test1 => handle : ${vnd.dovecot.mail_auto_reply_text}AutoReply: ${1}<default-from><NO-MIME>
START MESSAGE
END MESSAGE
Implicit keep:
- store message in folder: INBOX
sieve-test(root): Info: final result: success
The variable “vnd.dovecot.mail_auto_reply_text” is the trouble - it’s not being resolved, and I have no idea what the format of the variable should be.
Regards, Graham —
On 24. Sep 2020, at 22.50, Graham Leggett minfrin@sharp.fm wrote:
On 24 Sep 2020, at 20:45, Sami Ketola
mailto:sami.ketola@dovecot.fi> wrote: can you link your doveconf -n and the sieve script?
[root@gatekeeper ~]# cat /var/lib/dovecot-sieve/default.sieve #
require ["fileinto", "mailbox"]; require ["vacation", "variables"]; require ["vnd.dovecot.environment"];
I think this should be
require ["environment"];
instead.
Sami
On 24 Sep 2020, at 22:07, Sami Ketola sami.ketola@dovecot.fi wrote:
I think this should be
require ["environment"];
instead.
I eventually stumbled on a syntax that worked. Putting all of this in one place:
You need to turn on the sieve_extprograms plugin:
sieve_plugins = sieve_extprograms
Then you need to enable vnd.dovecot.environment:
sieve_global_extensions = +vnd.dovecot.environment
Then you need to pull the extra fields you want out of the userdb, and those fields must be prefixed with “sieve_env_”, like this example for LDAP:
user_attrs = mailMessageStore=home=%$,=sieve_env_mail_auto_reply_mode=%{ldap:mailAutoReplyMode},=sieve_env_mail_auto_reply_text=%{ldap:mailAutoReplyText}
Then you need to add a requirement on “vnd.dovecot.environment” to the sieve script.
Then, to access the variables in the sieve script, you need to drop the “sieve_env_” part, and add the prefix “env.vnd.dovecot.config.”. There are various docs floating around that reference the above variable without the leading “env.” - this must be there too.
The resulting sieve looks like this:
require ["fileinto", "mailbox"]; require ["vacation", "variables"]; require ["vnd.dovecot.environment"];
# fileinto: for putting mail into a imap folder # mailbox: for creating imap folder if not exists # if header :contains "X-Spam-Flag" "YES" { # move mail into folder Junk, create folder if not exists fileinto :create "Junk"; stop; }
if string :matches "${env.vnd.dovecot.config.mail_auto_reply_mode}" "reply" { if header :matches "subject" "*" { vacation :subject "AutoReply: ${1}" "${env.vnd.dovecot.config.mail_auto_reply_text}"; } }
- The output of sieve-test looks like this. The handle is weird, but I’m assuming there is method in the madness somehow:
sieve-test(root): Debug: sieve: Pigeonhole version 0.5.8 (b7b03ba2) initializing
sieve-test(root): Debug: sieve: include: sieve_global is not set; it is currently not possible to include :global' scripts. sieve-test(root): Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.5.8 (b7b03ba2) loaded debug: file storage: Using Sieve script path: /var/lib/dovecot-sieve/default.sieve. debug: file script: Opened script
default' from `/var/lib/dovecot-sieve/default.sieve'.
debug: Script binary /var/lib/dovecot-sieve/default.svbin successfully loaded.
debug: binary save: not saving binary /var/lib/dovecot-sieve/default.svbin, because it is already stored.
Performed actions:
- send vacation message: => seconds : 604800 => subject : AutoReply: Test1 => handle : ${env.vnd.dovecot.config.mail_auto_reply_text}AutoReply: ${1}<default-from><NO-MIME>
START MESSAGE I am truly away... END MESSAGE
Implicit keep:
- store message in folder: INBOX
sieve-test(root): Info: final result: success
Regards, Graham —
On 25/09/2020 11:33, Graham Leggett wrote:
On 24 Sep 2020, at 22:07, Sami Ketola
mailto:sami.ketola@dovecot.fi> wrote: I think this should be
require ["environment"];
instead.
I eventually stumbled on a syntax that worked. Putting all of this in one place:
- You need to turn on the sieve_extprograms plugin:
sieve_plugins = sieve_extprograms
This step is not needed for vnd.dovecot.environment. I don't see anything else in your Sieve script that makes this a requirement, so you should be able to remove it.
- Then you need to enable vnd.dovecot.environment:
sieve_global_extensions = +vnd.dovecot.environment
- Then you need to pull the extra fields you want out of the userdb, and those fields must be prefixed with “sieve_env_”, like this example for LDAP:
user_attrs = mailMessageStore=home=%$,=sieve_env_mail_auto_reply_mode=%{ldap:mailAutoReplyMode},=sieve_env_mail_auto_reply_text=%{ldap:mailAutoReplyText}
Then you need to add a requirement on “vnd.dovecot.environment” to the sieve script.
Then, to access the variables in the sieve script, you need to drop the “sieve_env_” part, and add the prefix “env.vnd.dovecot.config.”. There are various docs floating around that reference the above variable without the leading “env.” - this must be there too.
Where are those erroneous docs?
- The resulting sieve looks like this:
require ["fileinto", "mailbox"]; require ["vacation", "variables"]; require ["vnd.dovecot.environment"];
# fileinto: for putting mail into a imap folder # mailbox: for creating imap folder if not exists # if header :contains "X-Spam-Flag" "YES" { # move mail into folder Junk, create folder if not exists fileinto :create "Junk"; stop; }
if string :matches "${env.vnd.dovecot.config.mail_auto_reply_mode}" "reply" { if header :matches "subject" "*" { vacation :subject "AutoReply: ${1}" "${env.vnd.dovecot.config.mail_auto_reply_text}"; } }
- The output of sieve-test looks like this. The handle is weird, but I’m assuming there is method in the madness somehow:
sieve-test(root): Debug: sieve: Pigeonhole version 0.5.8 (b7b03ba2) initializing sieve-test(root): Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts. sieve-test(root): Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.5.8 (b7b03ba2) loaded debug: file storage: Using Sieve script path: /var/lib/dovecot-sieve/default.sieve. debug: file script: Opened script
default' from `/var/lib/dovecot-sieve/default.sieve'. debug: Script binary /var/lib/dovecot-sieve/default.svbin successfully loaded. debug: binary save: not saving binary /var/lib/dovecot-sieve/default.svbin, because it is already stored.Performed actions:
* send vacation message: => seconds : 604800 => subject : AutoReply: Test1 => handle : ${env.vnd.dovecot.config.mail_auto_reply_text}AutoReply: ${1}<default-from><NO-MIME>
START MESSAGE I am truly away... END MESSAGE
Implicit keep:
* store message in folder: INBOX
sieve-test(root): Info: final result: success
The handle is created implicitly and makes sure vacation avoids sending multiple identical responses within the :days (or :seconds) period. If you change the vacation command in the Sieve script, the handle changes, making sure that contacts get to see a new vacation message even when they've contacted the recipient within the :days period.
Regards,
Stephan.
Regards, Graham —
participants (3)
-
Graham Leggett
-
Sami Ketola
-
Stephan Bosch