First public revision
[imapami.git] / config-samples / simple / rules.yaml
1 #
2 # This is a configuration file of imapami.
3 # It is written in YAML.
4 # The full documentation of this configuration file is displayed
5 # with:
6 #   imapami --config-help
7 #
8
9 # Mandatory.
10 # Hostname or IP address of the IMAP server to connect to.
11 server: imap.example.com
12
13 # Optional.
14 # The TCP port to connect to. If not specified, use the default,
15 # depending on whether SSL is enabled or disabled.
16 # port: 143
17
18 # Mandatory.
19 # Enable or disable SSL (True or False).
20 ssl: True
21
22 # Optional.
23 # IMAP login name. If not specified, the login is asked on stdin.
24 login: user
25
26 # Optional.
27 # IMAP password.  If not specified, the password is asked on stdin.
28 password: cocolasticot
29
30 # Optional.
31 # File where messages are logged. If not specified, no logs are
32 # written in a file.
33 logfile: imapami.log
34
35 # Optional.
36 # Level of logs written in logfile. Possible value are from 0 (no log)
37 # to 4 (debug). Default value is 3 (info).
38 # loglevel: 3
39
40 # Optional.
41 # Default mailbox directory to get message from. If not specified,
42 # use INBOX.
43 # inbox: INBOX
44
45 # Any field that is not a reserved keyword is saved as a variable,
46 # and can be reused in rules with {var_name}.
47 me: toto@example.com
48
49 # List of rules. Each rule is composed of several fields:
50 # - the directory where the rule apply ("inbox"). If not specified,
51 #   the default mailbox directory is used.
52 # - a list condition ("if"). All of them must be true to match
53 #   the rule. They are all evaluated in the order they appear.
54 # - a list of action ("do"). They are all executed in the order
55 #   they appear.
56 # - a list of actions executed when condition does not match
57 #   ("else-do")
58 # - a list of actions executed on error when processing an
59 #   action list ("on-error-do").
60 rules:
61
62 # move some spam in another directory and mark as seen
63 - name: remove spam
64   if:
65   - or:
66     - regexp: {field: X-Spam-Status, pattern: 'Yes'}
67     - regexp: {field: Subject, pattern: '[Vv]iagra'}
68   do:
69   - log: {msg: 'spam:\n  Subject: {Subject}\n  From: {From}\n  To: {To}', level: 4}
70   - seen: {}
71   - move: {dest: Junk}
72
73 # move mailing list mails in a directory
74 - name: mailing list foo
75   if:
76   - regexp: {field: Subject, pattern: '\[foo\]'}
77   do:
78   - set-var: {ml: yes}
79   - move: {dest: foo}
80
81 # log if at least one ml message was processed
82 - name: log if some mailing list messages
83   if:
84   - eq: ['{ml}', 'yes']
85   do:
86   - log: {msg: 'some messages for mailing list'}
87
88 # pipe automation tasks to a script and mark as seen
89 - name: automation
90   if:
91   - regexp: {field: Subject, pattern: '\[auto\]'}
92   do:
93   - pipe: {command: '/usr/bin/my-prog'}
94   - seen: {}
95
96 # move mail whose To or Cc is me into another directory
97 - name: urgent mails
98   if:
99   - or:
100     - to: {substr: '{me}'}
101     - cc: {substr: '{me}'}
102   do:
103   - move: {dest: urgent}