pigeonhole/lda accessing -m folder
Hi all,
anybody knows, if there is a way to acces the folder from a call like this
deovecot-lda -m destfolder
from within a sieve script?
thx in advance matze
On Fri Aug 7 12:19:22 2015, matthias lay wrote:
anybody knows, if there is a way to acces the folder from a call like this
deovecot-lda -m destfolder
from within a sieve script?
Depending on what you mean by "access", this could be as easy as
require "fileinto";
fileinto "destfolder";
Yours Jost Krieger
| Jost.Krieger+sig@ruhr-uni-bochum.de Please help stamp out spam! | | Postmaster, JAPH, resident answer machine at RUB Comp. Center | | Sincere words are not sweet, sweet words are not sincere. | | Lao Tse, Tao Te King 81 |
hi jost thx for the reply,
by access I mean to read the variable
require ["fileinto", "variables", "?destfolder?" ];
if anyof ( destfolder :matches "*") {
fileinto "${1}/subfolder";
}else{
fileinto "INBOX/subfolder";
}
On 08/07/2015 12:26 PM, Jost Krieger wrote:
On Fri Aug 7 12:19:22 2015, matthias lay wrote:
anybody knows, if there is a way to acces the folder from a call like this
deovecot-lda -m destfolder
from within a sieve script?
Depending on what you mean by "access", this could be as easy as
require "fileinto";
fileinto "destfolder";
Yours Jost Krieger
fixed my problem.
if somebody is interested. I added an variable to the environment extension, which is quite easy. And the value of the folder is already there. so this is all:
src/lib-sieve/plugins/environment/ext-environment-common.c
static const char *envit_spfolder_get_value (struct sieve_instance *svinst, const struct sieve_script_env *senv) { return senv->default_mailbox; }
const struct sieve_environment_item spfolder_env_item = { .name = "spfolder", .get_value = envit_spfolder_get_value, };
after that the variable can easily be used in a script like
if anyof ( environment :matches "spfolder" "*") { set "myfolder" "${1}"; }
On 08/07/2015 12:40 PM, matthias lay wrote:
hi jost thx for the reply,
by access I mean to read the variable
require ["fileinto", "variables", "?destfolder?" ];
if anyof ( destfolder :matches "*") {
fileinto "${1}/subfolder";
}else{
fileinto "INBOX/subfolder";
}
On 08/07/2015 12:26 PM, Jost Krieger wrote:
On Fri Aug 7 12:19:22 2015, matthias lay wrote:
anybody knows, if there is a way to acces the folder from a call like this
deovecot-lda -m destfolder
from within a sieve script?
Depending on what you mean by "access", this could be as easy as
require "fileinto";
fileinto "destfolder";
Yours Jost Krieger
complete patch. some parts were missing before diff --git a/src/lib-sieve/plugins/environment/ext-environment-common.c b/src/lib-sieve/plugins/environment/ext-environment-common.c --- a/src/lib-sieve/plugins/environment/ext-environment-common.c +++ b/src/lib-sieve/plugins/environment/ext-environment-common.c @@ -24,7 +24,8 @@ static const struct sieve_environment_item *core_env_items[] = { &location_env_item, &phase_env_item, &name_env_item, - &version_env_item + &version_env_item, + &defaultfolder_env_item }; static unsigned int core_env_items_count = N_ELEMENTS(core_env_items); @@ -233,7 +234,19 @@ const struct sieve_environment_item version_env_item = { .value = PIGEONHOLE_VERSION, }; +/* "defaultfolder": + * the default folder where mail is stored when no rule matches + */ +static const char *envit_defaultfolder_get_value +(struct sieve_instance *svinst, + const struct sieve_script_env *senv) +{ + return senv->default_mailbox; +} - +const struct sieve_environment_item defaultfolder_env_item = { + .name = "defaultfolder", + .get_value = envit_defaultfolder_get_value, +}; diff --git a/src/lib-sieve/plugins/environment/ext-environment-common.h b/src/lib-sieve/plugins/environment/ext-environment-common.h --- a/src/lib-sieve/plugins/environment/ext-environment-common.h +++ b/src/lib-sieve/plugins/environment/ext-environment-common.h @@ -38,6 +38,7 @@ extern const struct sieve_environment_item location_env_item; extern const struct sieve_environment_item phase_env_item; extern const struct sieve_environment_item name_env_item; extern const struct sieve_environment_item version_env_item; +extern const struct sieve_environment_item defaultfolder_env_item; /* * Initialization On 08/07/2015 04:03 PM, matthias lay wrote:
fixed my problem.
if somebody is interested. I added an variable to the environment extension, which is quite easy. And the value of the folder is already there. so this is all:
src/lib-sieve/plugins/environment/ext-environment-common.c
static const char *envit_spfolder_get_value (struct sieve_instance *svinst, const struct sieve_script_env *senv) { return senv->default_mailbox; }
const struct sieve_environment_item spfolder_env_item = { .name = "spfolder", .get_value = envit_spfolder_get_value, };
after that the variable can easily be used in a script like
if anyof ( environment :matches "spfolder" "*") { set "myfolder" "${1}"; }
On 08/07/2015 12:40 PM, matthias lay wrote:
hi jost thx for the reply,
by access I mean to read the variable
require ["fileinto", "variables", "?destfolder?" ];
if anyof ( destfolder :matches "*") {
fileinto "${1}/subfolder";
}else{
fileinto "INBOX/subfolder";
}
On 08/07/2015 12:26 PM, Jost Krieger wrote:
On Fri Aug 7 12:19:22 2015, matthias lay wrote:
anybody knows, if there is a way to acces the folder from a call like this
deovecot-lda -m destfolder
from within a sieve script?
Depending on what you mean by "access", this could be as easy as
require "fileinto";
fileinto "destfolder";
Yours Jost Krieger
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Mon, 10 Aug 2015, matthias lay wrote: Hi Matthias, there is another possibility: require ["fileinto", "variables", "subaddress", "envelope"]; if envelope :detail :matches "to" "*" { set "myfolder" "${1}"; } else { set "myfolder" "INBOX"; } fileinto "my_${myfolder}"; stop; /usr/local/dovecot/libexec/dovecot/deliver -d user -m box -a user+box And enable the recipient_delimiter option. ===== Dear Stephan, If you find this code OK, please merge it into Pigeonhole. I find this information useful, too. The +detail and the default mailbox are not necessarily the same. Maybe, there is a namespace to expose this information easily? For the archive: + This works for both LDA and LMTP. + The Dovecot LDA requires option -m . + LMTP requires an active recipient_delimiter option. + If there is no -m option or no +detail, INBOX is the defaultfolder.
complete patch. some parts were missing before
diff --git a/src/lib-sieve/plugins/environment/ext-environment-common.c b/src/lib-sieve/plugins/environment/ext-environment-common.c --- a/src/lib-sieve/plugins/environment/ext-environment-common.c +++ b/src/lib-sieve/plugins/environment/ext-environment-common.c @@ -24,7 +24,8 @@ static const struct sieve_environment_item *core_env_items[] = { &location_env_item, &phase_env_item, &name_env_item, - &version_env_item + &version_env_item, + &defaultfolder_env_item };
static unsigned int core_env_items_count = N_ELEMENTS(core_env_items); @@ -233,7 +234,19 @@ const struct sieve_environment_item version_env_item = { .value = PIGEONHOLE_VERSION, };
+/* "defaultfolder": + * the default folder where mail is stored when no rule matches + */ +static const char *envit_defaultfolder_get_value +(struct sieve_instance *svinst, + const struct sieve_script_env *senv) +{ + return senv->default_mailbox; +}
- +const struct sieve_environment_item defaultfolder_env_item = { + .name = "defaultfolder", + .get_value = envit_defaultfolder_get_value, +};
diff --git a/src/lib-sieve/plugins/environment/ext-environment-common.h b/src/lib-sieve/plugins/environment/ext-environment-common.h --- a/src/lib-sieve/plugins/environment/ext-environment-common.h +++ b/src/lib-sieve/plugins/environment/ext-environment-common.h @@ -38,6 +38,7 @@ extern const struct sieve_environment_item location_env_item; extern const struct sieve_environment_item phase_env_item; extern const struct sieve_environment_item name_env_item; extern const struct sieve_environment_item version_env_item; +extern const struct sieve_environment_item defaultfolder_env_item;
/* * Initialization
On 08/07/2015 04:03 PM, matthias lay wrote:
fixed my problem.
if somebody is interested. I added an variable to the environment extension, which is quite easy. And the value of the folder is already there. so this is all:
src/lib-sieve/plugins/environment/ext-environment-common.c
static const char *envit_spfolder_get_value (struct sieve_instance *svinst, const struct sieve_script_env *senv) { return senv->default_mailbox; }
const struct sieve_environment_item spfolder_env_item = { .name = "spfolder", .get_value = envit_spfolder_get_value, };
after that the variable can easily be used in a script like
if anyof ( environment :matches "spfolder" "*") { set "myfolder" "${1}"; }
On 08/07/2015 12:40 PM, matthias lay wrote:
hi jost thx for the reply,
by access I mean to read the variable
require ["fileinto", "variables", "?destfolder?" ];
if anyof ( destfolder :matches "*") {
fileinto "${1}/subfolder";
}else{
fileinto "INBOX/subfolder";
}
On 08/07/2015 12:26 PM, Jost Krieger wrote:
On Fri Aug 7 12:19:22 2015, matthias lay wrote:
anybody knows, if there is a way to acces the folder from a call like this
deovecot-lda -m destfolder
from within a sieve script?
Depending on what you mean by "access", this could be as easy as
require "fileinto";
fileinto "destfolder";
Yours Jost Krieger
- -- Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEVAwUBVci1LXz1H7kL/d9rAQJJogf+PJl87IL3KEmc3uPDi7q8yJBRTChmqlGN 39SrJ6DGfe8+IZSlipJZzAAnE/nn+D/YHGcS20X40Nas4QassoZi16ZfX6OGId1O 8IvYjGc0k0Mu8Nnk0vyX0DwTA23oId0y934HCQxhxvgS6bM9iexA+Fs2KPA2ta+9 xOEtpjQCTvYFX6VvqhjQaz6lv/f+mSEoU/EFbvC9jMNV+v4a2SQ3Dazfg6OAoRUp WfXjYAgmvsH/xbL/QGqzFkJX/1vVTBX8wJRDoZHC/XcWNr2775VFQHaO4PQrPAr/ 48dHbiSwinGLBD4RkLVq7l9zZWfuxf6EMTmdNWHRO49cE3ZahxBtoQ== =Jq9R -----END PGP SIGNATURE-----
Op 8/10/2015 om 4:29 PM schreef Steffen Kaiser:
On Mon, 10 Aug 2015, matthias lay wrote:
Dear Stephan,
If you find this code OK, please merge it into Pigeonhole.
Non-standard entries like this require a vnd.dovecot prefix.
I find this information useful, too. The +detail and the default mailbox are not necessarily the same. Maybe, there is a namespace to expose this information easily?
The Pigeonhole internals support custom variable namespaces. The extdata plugin uses this too, so adding something like that is architecturally not problematic.
I would make this dependent on an extension like "vnd.dovecot.environment", so that non-standard features are only added when this is in the require line. Currently, the "auth" envelope field (CMUSieve) is the only exception and I like to keep it that way.
I'll give this a look. Also, are there any other environment items that may be useful?
Regards,
Stephan.
hi stephan,
On 08/10/2015 05:05 PM, Stephan Bosch wrote:
I'll give this a look. Also, are there any other environment items that may be useful?
when I checked the environment plugin I was wondering cuz it was not what I was thinking it would be, .....before reading the RFC ;)
would it be a bad idea to have a generic environment extension working with getenv() to be able to get all kind of self defined, prefixed variables in program environment?
Greetz Matze
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Mon, 10 Aug 2015, Stephan Bosch wrote:
I would make this dependent on an extension like "vnd.dovecot.environment", so that non-standard features are only added
Yes, sure :-)
Maybe to place it into a vnd.dovecot. namespace of the variable extension is even simplier?
I'll give this a look. Also, are there any other environment items that may be useful?
Hm,
the current user for global scripts.
can you differ between "INBOX" specified explicitly or implicitly, I mean as result of the -m option or in LMTP via subaddress? This is what I need in some scripts, "if there is no explicit destination folder given, fileinto XYZ". The default_folder information comes very near to it.
Because I use LMTP rather then LDA as Matthias I wonder if you can make user-related information available, that can be configured via conf-file?
There had been a request about matching the subaddress against existing mail folders case-insensitively. I guess it is great performance penalty to read a complete list of mail folders of the user into the environment, so one can match against it?
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1
iQEVAwUBVcrlcnz1H7kL/d9rAQLNqAgAwL191ZlJicE2DNGbgKPV1VrvC4/Vg7iD HShfyiTqLFSmPUM1W07CBYtXKFdcnYPno/jbnhM8Qz3R2lgDoOIPvUFaxL8CKUnt t2/z1ZOg6qrMynLDr986Zvc6Yjbu0aX5/Ga02uvRWiKl8Zxp/NkIzA8F99b2Vn3i G0aDCYy6PG3pdNsPJ0zthIDVdkkmF4Kre3N2ufECF9tOcFizbs4tRrUXD1Gu0xlu W3pM+oRtACKkgHJufgXO0jhx0WBt370E7JSVO4M0KFnFfpoOCZk16OiYMJDDj/wL YlI52+TTlPy1+CBQTuWA8jWY5g5n8gBrCXZ3mFEiMjM03wRhn2hmSQ== =7bN5 -----END PGP SIGNATURE-----
I just noticed you implemented the Dovecot Environment Extension. Thanks!
maybe it helps somebody to get this referenced in this thread
https://raw.githubusercontent.com/dovecot/pigeonhole/master/doc/rfc/spec-bos...
example: default folder is accessible with:
${env.vnd.dovecot.default_mailbox}
Greetz Matze
Am Mon, 10 Aug 2015 17:05:58 +0200 schrieb Stephan Bosch stephan@rename-it.nl:
Op 8/10/2015 om 4:29 PM schreef Steffen Kaiser:
On Mon, 10 Aug 2015, matthias lay wrote:
Dear Stephan,
If you find this code OK, please merge it into Pigeonhole.
Non-standard entries like this require a vnd.dovecot prefix.
I find this information useful, too. The +detail and the default mailbox are not necessarily the same. Maybe, there is a namespace to expose this information easily?
The Pigeonhole internals support custom variable namespaces. The extdata plugin uses this too, so adding something like that is architecturally not problematic.
I would make this dependent on an extension like "vnd.dovecot.environment", so that non-standard features are only added when this is in the require line. Currently, the "auth" envelope field (CMUSieve) is the only exception and I like to keep it that way.
I'll give this a look. Also, are there any other environment items that may be useful?
Regards,
Stephan.
participants (5)
-
Jost Krieger
-
matthias lay
-
Matthias Lay
-
Steffen Kaiser
-
Stephan Bosch