On 18/02/2021 12:53, Yassine Chaouche wrote:> Yo Denis, > > As bjoern and Anton already said, you need a sieve script > that has a rule that says every mail that has the "detail" > keyword in the "to" header must go to the "detail" folder. > > It works with static values. But I don't know if you can > dynmicaly create folders with the "detail" part put in a > variable for example, ask the sieve to create it if it > doesn't exist, then deliver mail to it.What I use is: if envelope :detail :regex "to" "(.+)" { ??? set :upperfirst :lower "detail" "${1}"; ??? fileinto :create "Tagged/${detail}"; ??? stop; } Which says "if the envelope detail is not empty, copy it to a variable called 'detail' and titlecase it, then file the message into Tagged/$detail, creating that if necessary". I think the most relevant part here is using a regex to match on the detail - that copies the value of the detail into $1, which you can then use as you see fit.> > Yassine > > Le 2/18/21 ? 1:27 PM, Bjoern Franke a ?crit?: >> Hi, >> >>> So, there is now way that Dovecot can create folders with "detail" >>> name for mail sent to "alias+detail" address? >>> >> did you take a look into the logs? E.g. in my setup, dovecot complains >> when sieve should put the message into a folder which does not exist. >> >> Maybe it logs something also in your case why it does not create the >> folder. >> >> Regards >> Bjoern >-------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 840 bytes Desc: OpenPGP digital signature URL: <https://dovecot.org/pipermail/dovecot/attachments/20210218/c5895436/attachment.sig>
Le 2/18/21 ? 2:08 PM, Darac Marjal a ?crit?:> What I use is: > if envelope :detail :regex "to" "(.+)" { > ??? set :upperfirst :lower "detail" "${1}"; > ??? fileinto :create "Tagged/${detail}"; > ??? stop; > } > > Which says "if the envelope detail is not empty, copy it to a variable > called 'detail' and titlecase it, then file the message into > Tagged/$detail, creating that if necessary". I think the most relevant > part here is using a regex to match on the detail - that copies the > value of the detail into $1, which you can then use as you see fit. >Excellent ! thanks for sharing. This was added to my info.txt file. Yassine -- admin sysweb.
On Thu, 18 Feb 2021 13:08:28 +0000 Darac Marjal <mailinglist at darac.org.uk> wrote:> What I use is: > > if envelope :detail :regex "to" "(.+)" { > ??? set :upperfirst :lower "detail" "${1}"; > ??? fileinto :create "Tagged/${detail}"; > ??? stop; > } > > Which says "if the envelope detail is not empty, copy it to a variable > called 'detail' and titlecase it, then file the message into > Tagged/$detail, creating that if necessary". I think the most relevant > part here is using a regex to match on the detail - that copies the > value of the detail into $1, which you can then use as you see fit.Hi! Are you sure it works with aliases? I have tried putting it in my sieve, but for me it works only for "user+detail", i.e. when I use an actually existing user name + detail. If I use an "alias+detail", the message is still dropped into INBOX. -- Respectfully, Denis Shadrin
On Thu, 18 Feb 2021 13:08:28 +0000 Darac Marjal <mailinglist at darac.org.uk> wrote:> What I use is: > > if envelope :detail :regex "to" "(.+)" { > ??? set :upperfirst :lower "detail" "${1}"; > ??? fileinto :create "Tagged/${detail}"; > ??? stop; > } > > Which says "if the envelope detail is not empty, copy it to a variable > called 'detail' and titlecase it, then file the message into > Tagged/$detail, creating that if necessary". I think the most relevant > part here is using a regex to match on the detail - that copies the > value of the detail into $1, which you can then use as you see fit.(The reply seems to have been lost, so I'm sending it again, with some edits) Hi! Are you sure it works with aliases? I have tried putting it in my sieve, but for me it works only for "user+detail", i.e. when I use an actually existing user name + detail. If I use an "alias+detail", the message is still dropped into INBOX. And I guess I now understand why: when a message is trancferred by dovecot-lmtp from an alias to the end user, it loses its detail part of the "Envelope-To". The detail part of the address is preserved only in the header "To". So there are two questions: 1. Is there a way to make dovecot-lmtp preserve the detail part of the address in the envelope? or 2. Is there a way to cut a part of the address from the header "To"? I mean, cut the part between the + and the @ and use this part as a variable for fileinto. I have tried this: if header :matches "to" "+(*)@" { fileinto :create "Tagged/${1}"; stop; } but the message is still dropped into INBOX. -- Respectfully, Denis Shadrin