Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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

This comment has been minimized.

Copy link
Owner Author

shuairan commented Aug 20, 2012

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
You can’t perform that action at this time.