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.

The configuration starts with one or many maildir definitions. Each maildir is associated with a block of rules. For each message present in a maildir, each rule is evaluated in sequential order where the first matching rule is favored.

maildir “path” { rule ... }
    A maildir rooted in path; mdsort(1) iterates over each message present in the cur and new directory.

stdin { rule ... }
    Accepts a message from stdin. This type of maildir will only be evaluted if mdsort(1) is invoked with the stdin option.

A rule is defined as follows:

match condition action ...
    A rule starts with the match keyword followed by a condition then actions to perform if the condition evaluates to true. 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]

    []! 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.

    []! attachment Evaluates to true if the message has attachments.

    []! attachment /pattern/[i] Evaluates to true if the message has attachments with a content type matching pattern.

    []! date > age scale

    []! date < age scale Evalutes to true if the date header in message is either greater or less than age, which must be a positive number. The scale must be either seconds, minutes, hours, days, weeks, months or years. It may be abbreviated in a non-ambiguous way, such as second or s.

    []! all Evaluates to true for any message.

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

    []! old Evaluates to true if the message is old. Meaning, a message that has been read but later flagged as not read.

    Multiple and nested conditions may also be 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:

    break
        Abort evaluation of the current block of rules. Especially useful when using nested match blocks, see below. Mutually exclusive with all other actions.

    discard
        Remove the message from the maildir. Mutually exclusive with all other actions.

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

    move “path”
        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. Note, using back-references with many or conditions is not encouraged since the pattern that matches first may vary.

        Only one move action can be defined per rule.

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"
    }
    maildir "~/Maildir/Trash" {
    	# Delete messages older than 2 weeks.
    	match date > 2 weeks discard
    }
    # Accept messages from stdin and move to the invoking user's inbox.
    stdin {
    	match all move "~/Maildir/INBOX"
    }

SEE ALSO
mdsort(1), re_format(7)

AUTHORS
Anton Lindqvist <anton@basename.se>