Skip to content

Instantly share code, notes, and snippets.

@shuairan
Created August 20, 2012 18:38
Show Gist options
  • Save shuairan/3406526 to your computer and use it in GitHub Desktop.
Save shuairan/3406526 to your computer and use it in GitHub Desktop.
[Uberspace] Maildrop mailfilter: Sort subaddress-mails into already existing subdirs.
MAILDIR = "$HOME/Maildir"
DEFAULT = "$MAILDIR"
# EMails an Erweiterungen in Unterordner verschieben falls dieser existiert
if (/^To: .*mail-(.*)@example.com/:h)
{
SUBMAILDIR = `find $MAILDIR -iname ".$MATCH1" | head -n 1`
`test -d $EMAILDIR/new && exit 1 || exit 0`
if ( $RETURNCODE == 1 )
{
to "$SUBMAILDIR";
}
}
# Standardregel:
to "$DEFAULT"
@shuairan
Copy link
Author

Sorts subaddress-mails (mails including a dash: mail-test@example.com) into a subdir if a suitable (case insensitive) directory exists.
This mailfilter doesn't create new subdirectorys, which can be configured via IMAP Client and/or Roundcube (because I don't want to sort ALL my different subaddresses into subdirs)

To use this script change line 5 to match your personal mail address.
If you want all mail-test@example.com to be placed in a subdirectory "Test", simply create that subfolder and your future mail to "mail-test@example.com" will be sorted there. (existing mails have to be moved manually, maildrop only applies to incoming mails)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment