Skip to content

Instantly share code, notes, and snippets.

@epilys
Created February 23, 2024 16:27
Show Gist options
  • Save epilys/bf190ffb0147aa5ab863f7fa886a27da to your computer and use it in GitHub Desktop.
Save epilys/bf190ffb0147aa5ab863f7fa886a27da to your computer and use it in GitHub Desktop.
sieve filter to create new List mailboxes according to List-ID value
#require ["fileinto", "mailbox", "variables", "vnd.dovecot.debug", "regex"];
require ["fileinto", "mailbox", "variables", "regex", "vnd.dovecot.execute"];
if not exists "X-GitHub-Recipient" {
if header :regex :comparator "i;octet" "list-id" "(.*)" {
#set :lower "listid_raw" "${1}";
execute :input "${1}" :output "listid" "sanitize_name.sh";
fileinto :create "INBOX.Lists.${listid}";
stop;
} elsif header :matches :comparator "i;octet" "list-id" "*" {
fileinto "INBOX.Lists";
stop;
}
}
if exists "X-GitHub-Recipient" {
fileinto "INBOX.github";
stop;
}
#!/bin/sh
export LC_ALL=C
tr --squeeze-repeats '[:space:]' '_' | tr --squeeze-repeats '[:punct:]' '-' | tr --squeeze-repeats --delete '[:cntrl:]' '' | tr --squeeze-repeats --delete '[:blank:]' '' | sed -e 's/^[[:punct:]]*//' -e "s/[[:punct:]]*$//g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment