PATCH for Stephan: Re: pigeonhole/lda accessing -m folder
Steffen Kaiser
skdovecot at smail.inf.fh-brs.de
Mon Aug 10 14:29:01 UTC 2015
-----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-----
More information about the dovecot
mailing list