MDSORT.CONF(5)

NAME
mdsort.conf - mdsort configuration file

DESCRIPTION
mdsort.conf is the configuration file for mdsort(1).

Comments can be put anywhere in the file using a hash mark (‘#’) and extend to the end of the current line.

Each maildir section starts with a declaration of the maildir and its corresponding path:

maildir “path” { rule ... }

Followed by a block of rules. mdsort(1) iterates over each message present in the cur and new directory rooted in path and evaluates each rule in sequential order. The first matching rule is favored.

A rule is defined as follows:

match condition action
    A rule starts with the match keyword followed by one or many conditions and an action. Each rule spans to the end of the current line but can extended over multiple lines using a backslash (‘\’).

    A pattern used within a condition is interpreted as an extended regular expression and can be made case insensitive using the i keyword.

    The conditions are as follows and may be negated:

    [!] body /pattern/[i]
        Evaluates to true if the message body matches pattern.

    [!] header “name” /pattern/[i]
        Evaluates to true if the value of the header with name in message matches pattern. Finding the header with name in message is done case insensitive.

    [!] header { “name” ... } /pattern/[i]
        Evaluates to true if the value of any of the headers with name ... in message matches pattern. Finding the header with name ... in message is done case insensitive.

    [!] new
        Evaluates to true if the message is not read.

    all Evaluates to true for any message.

    Multiple and nested conditions may be also specified:

    condition and condition
        Evaluates to true if both condition are true.

    condition or condition
        Evaluates to true if any of the condition are true.

    [!] (condition)
        Evaluates to true if the nested condition is true.

    Next comes one or many actions:

    move “path”
        If the condition(s) evaluates to true, move the message to the maildir located at path. The path may contain back-references on the form ‘\#’ where ‘#’ is a digit. The digit refers to the nth subexpression of the first matching pattern and will be replaced with matched string. Using back-references with many or conditions is not encouraged since the pattern that matches first may vary.

        Only one move action may be defined per rule.

    flag [!] new
        Flag the message as read or not.

match condition { rule ... }
    The nested block of rules is only evaluated if condition is true.

FILES

~/.mdsort.conf
    The default configuration file.

EXAMPLES

    maildir "~/Maildir/INBOX" {
    	# Move messages from OpenBSD mailing lists into dedicated directories.
    	match header { "Cc" "To" } /(bugs|misc|ports|tech)@openbsd.org/i \
    		move "~/Maildir/openbsd-\1"
    	# Get rid of potential spam.
    	match header "Received-SPF" /fail/ or header "X-Spam-Score" /[1-9]/ \
    		move "~/Maildir/Spam"
    	# Archive read messages.
    	match ! new move "~/Maildir/Archive"
    }

SEE ALSO
mdsort(1), re_format(7)

AUTHORS
Anton Lindqvist <anton.lindqvist@gmail.com>