Creating new mailboxes

The maildrop utility will not create new mailboxes on its own, they must exist before maildrop will deliver mail to them. The maildirmake utility can be used to create a maildir folder or initialize your maildir storage area.

To initialize the maildir storage area, use this command:

      maildirmake $HOME/Maildir

To create a mail folder called folder, use this command:

      maildirmake -f folder $HOME/Maildir

Note that creating a new mail folder will not subscribe your IMAP client to the new folder. You will need to subscribe to the new folder before it will appear in your IMAP client's folder list.

Filtering mail with maildrop mailfilter

The mail server uses maildrop to deliver mail. The maildrop utility has an extensive filtering engine to sort incoming e-mail based on regular expressions. By default, mail will be delivered to your INBOX folder. To create filtering rules, create a file called .mailfilter in your home directory. A typical mail filter rule will have a structure as such:

     if (/regular expression/)
          to $HOME/Maildir/.folder/

The above rule will deliver messages matching regular expression into the mail folder called folder in your maildir storage area. Note the dot preceding the folder name and the trailing slash after the folder name.

In order for this rule to be applied, the folder has to exist already. Maildrop will not create maildir folders automatically. Also, be sure to give the trailing slash after the destination folder. Without the trailing slash, maildrop assumes its delivering to an mbox style mailbox, not the case with maildir format.

An example rule for filtering out messages that spamassassian has flagged as spam:

     if (/^X-Spam-Flag: YES/:h )
          to $HOME/Maildir/.spam/

Syntax checking your mailfilter rules

If maildrop runs into a syntax error when parsing your rules, it will exit with a temporary failure. The mail server will then hold the mail for your account and try again later. To syntax check your filter rules, you can feed maildrop an empty input, and it will print out any syntax errors it discovered.

      maildrop < /dev/null