I've Dovecot and dovecot-sieve v 2.2.27 installed on a Debian 9.6. I'm trying to set a Sieve filter which will redirect all emails from `info` (i.e. .info) TLD to another email. This is the filter: require ["regex"]; # rule:[test] if header :regex "from" "info$" { redirect "subbs at domain.com"; } It's not being honored; all emails from .info TLD ends up in the inbox and none are redirected. Let me know what I'm doing wrong. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://dovecot.org/pipermail/dovecot/attachments/20190220/2877333d/attachment.html>
Why do you use regex ? You can just use matches: https://p5r.uk/blog/2011/sieve-tutorial.html#matchtype (https://p5r.uk/blog/2011/sieve-tutorial.html#matchtype) On Wed, Feb 20, 2019 at 03:31 AM, subin ks via dovecot wrote: I've Dovecot and dovecot-sieve v 2.2.27 installed on a Debian 9.6. I'm trying to set a Sieve filter which will redirect all emails from `info` (i.e. .info) TLD to another email. This is the filter: require ["regex"]; # rule:[test]if header :regex "from" "info$"{ redirect "subbs at domain.com (mailto:subbs at domain.com)";} It's not being honored; all emails from .info TLD ends up in the inbox and none are redirected. Let me know what I'm doing wrong. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://dovecot.org/pipermail/dovecot/attachments/20190220/efbb89bd/attachment-0001.html>
Hi! You forgot the wildcard '.*'?(=?Match zero or more instances of any single character, except newline) require ["regex"]; # rule:[test] if header :regex "from" ".*info$" { ? redirect "subbs at domain.com"; } With this rule, you are filtering emails from toplevel domain '*.info' or new domains that might occur in future (e.g '*.superinfo'). If you want to restrict to classic tld '*.info' change the regex to ".*\.info$" The draft lists a table of common regex in section2: https://tools.ietf.org/html/draft-murchison-sieve-regex-08#section-2 There are online regex checker like https://regex101.com thought not specific to sieve's regex, which can be used to test your regular expressions. Sieve's regex are quite standard though. Greetings Martin On Wed, 2019-02-20 at 14:00 +0530, subin ks via dovecot wrote:> I've Dovecot and dovecot-sieve?v?2.2.27 installed on a Debian 9.6. > I'm trying to set a Sieve filter which will redirect all emails from > `info` (i.e. .info) TLD to another email. This is the filter: > > require ["regex"]; > # rule:[test] > if header :regex "from" "info$" > { > redirect "subbs at domain.com"; > } > > It's not being honored; all emails from .info TLD ends up in the > inbox and none are redirected. Let me know what I'm?doing wrong. > > Thanks. >
On Wed, 2019-02-20 at 10:18 +0100, Martin Johannes Dauser via dovecot wrote:> Hi! > > You forgot the wildcard '.*'?(=?Match zero or more instances of any > single character, except newline) > > require ["regex"]; > # rule:[test] > if header :regex "from" ".*info$" > { > ? redirect "subbs at domain.com"; > } > > With this rule, you are filtering emails from toplevel domain > '*.info' > or new domains that might occur in future (e.g '*.superinfo'). If you > want to restrict to classic tld '*.info' change the regex to > > ".*\.info$"Oh, and if you want to include a TLD like "*.superinfos" The regex needs to be ".*\..*info[^.]$"> > > The draft lists a table of common regex in section2: > https://tools.ietf.org/html/draft-murchison-sieve-regex-08#section-2 > > > There are online regex checker like https://regex101.com thought not > specific to sieve's regex, which can be used to test your regular > expressions. Sieve's regex are quite standard though. > > Greetings > Martin > > > On Wed, 2019-02-20 at 14:00 +0530, subin ks via dovecot wrote: > > I've Dovecot and dovecot-sieve?v?2.2.27 installed on a Debian 9.6. > > I'm trying to set a Sieve filter which will redirect all emails > > from > > `info` (i.e. .info) TLD to another email. This is the filter: > > > > require ["regex"]; > > # rule:[test] > > if header :regex "from" "info$" > > { > > redirect "subbs at domain.com"; > > } > > > > It's not being honored; all emails from .info TLD ends up in the > > inbox and none are redirected. Let me know what I'm?doing wrong. > > > > Thanks. > >
Scott, you are right. And I guess it's computed faster too. # rule:[test] if header :matches "from" "*.info" { redirect "subbs at domain.com"; } Even a TLD like "*.superinfos" may be included: "*@*.*info*" Greetings Martin On Wed, 2019-02-20 at 08:47 +0000, Scott M. via dovecot wrote:> Why do you use regex ? > > You can just use matches:?https://p5r.uk/blog/2011/sieve-tutorial.htm > l#matchtype > > > > > > On Wed, Feb 20, 2019 at 03:31 AM, subin ks via dovecot <dovecot at dovec > ot.org> wrote: > I've Dovecot and dovecot-sieve?v?2.2.27 installed on a Debian 9.6. > I'm trying to set a Sieve filter which will redirect all emails from > `info` (i.e. .info) TLD to another email. This is the filter: > > require ["regex"]; > # rule:[test] > if header :regex "from" "info$" > { > redirect "subbs at domain.com"; > } > > It's not being honored; all emails from .info TLD ends up in the > inbox and none are redirected. Let me know what I'm?doing wrong. > > Thanks. >
Op 20-2-2019 om 9:30 schreef subin ks via dovecot:> I've Dovecot and dovecot-sieve?v?2.2.27 installed on a Debian 9.6. I'm > trying to set a Sieve filter which will redirect all emails from > `info` (i.e. .info) TLD to another email. This is the filter: > > require ["regex"]; > # rule:[test] > if header :regex "from" "info$" > { > redirect "subbs at domain.com <mailto:subbs at domain.com>"; > } > > It's not being honored; all emails from .info TLD ends up in the inbox > and none are redirected. Let me know what I'm?doing wrong.You should use the "address" test instead. This parses the header for addresses. Using the "header" test this way is unreliable. For example, an address wrapped in <...> is not handled well by your attempt. So, this is better: if address :matches :domain "from" "*.info" { redirect "subbs at domain.com <mailto:subbs at domain.com>"; } Regards, Stephan.