筛假描述于https://www.rfc-editor.org/rfc/rfc5230允许定义并由 dovecot 发送休假消息。
默认情况下,休假消息的文本在筛选脚本中是硬编码的。
如何从 dovecot userdb 的额外字段填充休假消息文本,以便多个用户可以共享相同的筛选脚本,但仍可以在 LDAP 中自定义他们的休假消息?
答案1
综上所述,要实现这一目标,需要完成许多步骤:
- 您需要打开 sieve_extprograms 插件:
sieve_plugins = sieve_extprograms
- 然后需要启用vnd.dovecot.environment:
sieve_global_extensions = +vnd.dovecot.environment
- 然后你需要从 userdb 中提取你想要的额外字段,这些字段必须以筛子环境,例如 LDAP 的这个示例:
user_attrs = mailMessageStore=home=%$,=sieve_env_mail_auto_reply_mode=%{ldap:mailAutoReplyMode},=sieve_env_mail_auto_reply_text=%{ldap:mailAutoReplyText}
然后,您需要按照以下示例向筛选脚本添加对“vnd.dovecot.environment”的要求。
然后,要访问筛选脚本中的变量,您需要删除“筛子环境“部分,并添加前缀“环境.vnd.dovecot.config。“。有各种各样的文档引用了上述变量,但没有以“env”开头——这也必须存在。
最终得到的筛子如下:
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}";
}
}
- sieve-test 的输出如下所示。句柄很奇怪,但我假设其中一定有方法:
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