Configuration

Configuration files are written in YAML. A short introduction to the YAML syntax is given in the chapter YAML Syntax. A minimal configuration file would look like this:

accounts:
    Google Mail:
        address: imap.gmail.com
        username: john.doe@gmail.com
        password: _My_PaSswOrd_
        ssl: true
        time-out: 300
        idle: on
        folders:
            - [INBOX, {filter: rbl, org: bl.spamcop.net, action: delete}]
        smtp:
            host: smtp.gmail.com

logging:
    version: 1
    formatters:
        default:
            format: '%(asctime)s:%(name)-32s:%(funcName)-16s:%(levelname)-8s: %(message)s'
    handlers:
        mailfilter:
            class: logging.handlers.RotatingFileHandler
            formatter: default
            # FILENAME:
            filename: _test/log
            backupCount: 4
            maxBytes: 4194304
    loggers:
        mailfilter:
            handlers: [mailfilter]
            # LOG LEVEL:
            level: INFO

As you see there are two sections, the latter one only concerned about logging. More about that in the logging chapter.

The main section for defining IMAP accounts and what should happen with them is defined in the accounts section.

Account definition

The address item specifies the domain name of the IMAP server, username and password the account credentials. If SSL is to be used, an ssl item may be given with a value of true, yes or on. If it is missing, false is assumed.

A time-out item, expressed in seconds, specifies how often to poll the account. A time-out value can also be specified in the global section.

If the server provides IDLE push notifications, idle with a True value can be added. If idle is missing, False is assumed.

The folders to be examined are specified in the folders item as a list. Each item is a list consisting of a folder name and a filter specification.

Forwarding an email requires access to an SMTP server. The smtp section in the account requires a host item specifying the server’s domain name. Optionally, a username and password item may be given if they are different from the ones in the account definition. An smtp section can also be put into the global section, which will provide a default specification.