On 24 Sep 2020, at 20:45, Sami Ketola <sami.ketola at dovecot.fi> wrote:> can you link your doveconf -n and the sieve script?The user?s detail are: [root at gatekeeper ~]# doveadm user minfrin at example.com field value uid vmail gid vmail home /home/vmail/minfrin at example.com/ mail maildir:~/mail mail_auto_reply_mode reply mail_auto_reply_text I am truly away... The sieve script is: [root at 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 at 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 = </etc/device/services/mail-server/ssl-cert.pem ssl_cipher_list = PROFILE=SYSTEM ssl_key = # hidden, use -P to show it submission_relay_host = localhost submission_relay_trusted = yes userdb { args = /etc/dovecot/dovecot-ldap.conf.ext driver = ldap } 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 ? -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://dovecot.org/pipermail/dovecot/attachments/20200924/a3849e54/attachment-0001.html>
Sami Ketola
2020-Sep-24 20:07 UTC
[EXT] How do I make "vnd.dovecot.environment" available?
> On 24. Sep 2020, at 22.50, Graham Leggett <minfrin at sharp.fm> wrote: > > On 24 Sep 2020, at 20:45, Sami Ketola <sami.ketola at dovecot.fi <mailto:sami.ketola at dovecot.fi>> wrote: > >> can you link your doveconf -n and the sieve script? > > [root at 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://dovecot.org/pipermail/dovecot/attachments/20200924/154c72cb/attachment.html>
Graham Leggett
2020-Sep-25 09:33 UTC
[EXT] How do I make "vnd.dovecot.environment" available?
On 24 Sep 2020, at 22:07, Sami Ketola <sami.ketola at 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 ? -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://dovecot.org/pipermail/dovecot/attachments/20200925/14b4becb/attachment.html>