Filter mailing lists with Dovecot Sieve

require ["fileinto", "variables"];

if header :matches "List-Post" "*<mailto:**@*.*.*>" {
  fileinto "INBOX.lists.${5}.${3}"; stop;
}

if header :matches "List-Post" "*<mailto:**@*.*>" {
  fileinto "INBOX.lists.${4}.${3}"; stop;
}

if header :matches "X-Mailing-List" "*@*.*.*" {
  fileinto "INBOX.lists.${3}.${1}"; stop;
}

if header :matches "X-Mailing-List" "*@*.*" {
  fileinto "INBOX.lists.${2}.${1}"; stop;
}