Browse Source

clone from private repo

master
iburadempa 4 months ago
commit
c0ae983acb
48 changed files with 2766 additions and 0 deletions
  1. 1
    0
      README.md
  2. 59
    0
      mail_system.yml
  3. 50
    0
      mail_system/tasks/clamav.yml
  4. 133
    0
      mail_system/tasks/database.yml
  5. 125
    0
      mail_system/tasks/dovecot.yml
  6. 6
    0
      mail_system/tasks/main.yml
  7. 79
    0
      mail_system/tasks/postfix.yml
  8. 10
    0
      mail_system/tasks/remove_other_mtas.yml
  9. 81
    0
      mail_system/tasks/rspamd.yml
  10. 133
    0
      mail_system/templates/dovecot/10-auth.conf
  11. 461
    0
      mail_system/templates/dovecot/10-mail.conf
  12. 154
    0
      mail_system/templates/dovecot/10-master.conf
  13. 86
    0
      mail_system/templates/dovecot/15-mailboxes.conf
  14. 102
    0
      mail_system/templates/dovecot/20-imap.conf
  15. 30
    0
      mail_system/templates/dovecot/20-lmtp.conf
  16. 24
    0
      mail_system/templates/dovecot/90-acl.conf
  17. 18
    0
      mail_system/templates/dovecot/90-plugin.conf
  18. 107
    0
      mail_system/templates/dovecot/90-quota.conf
  19. 49
    0
      mail_system/templates/dovecot/90-sieve-extprograms.conf
  20. 234
    0
      mail_system/templates/dovecot/90-sieve.conf
  21. 3
    0
      mail_system/templates/dovecot/README_after
  22. 40
    0
      mail_system/templates/dovecot/README_before
  23. 13
    0
      mail_system/templates/dovecot/README_execute
  24. 15
    0
      mail_system/templates/dovecot/README_filters
  25. 42
    0
      mail_system/templates/dovecot/auth-sql.conf.ext
  26. 65
    0
      mail_system/templates/dovecot/dovecot-dict-sql.conf.ext
  27. 174
    0
      mail_system/templates/dovecot/dovecot-sql.conf.ext
  28. 107
    0
      mail_system/templates/dovecot/dovecot.conf
  29. 5
    0
      mail_system/templates/dovecot/learn-ham.sieve
  30. 5
    0
      mail_system/templates/dovecot/learn-spam.sieve
  31. 2
    0
      mail_system/templates/dovecot/rspamd-learn-ham.sh
  32. 2
    0
      mail_system/templates/dovecot/rspamd-learn-spam.sh
  33. 9
    0
      mail_system/templates/dovecot/spam-to-folder.sieve
  34. 10
    0
      mail_system/templates/postfix/aliases.cf
  35. 10
    0
      mail_system/templates/postfix/domains.cf
  36. 10
    0
      mail_system/templates/postfix/email_existence_check.cf
  37. 1
    0
      mail_system/templates/postfix/header_checks
  38. 10
    0
      mail_system/templates/postfix/mailboxes.cf
  39. 106
    0
      mail_system/templates/postfix/main.cf
  40. 146
    0
      mail_system/templates/postfix/master.cf
  41. 10
    0
      mail_system/templates/postfix/relay_domains.cf
  42. 10
    0
      mail_system/templates/postfix/relay_recipient_maps.cf
  43. 10
    0
      mail_system/templates/postfix/transport_maps.cf
  44. 7
    0
      mail_system/templates/rspamd/antivirus.conf
  45. 2
    0
      mail_system/templates/rspamd/arc.conf
  46. 4
    0
      mail_system/templates/rspamd/classifier-bayes.conf
  47. 2
    0
      mail_system/templates/rspamd/dkim_signing.conf
  48. 4
    0
      mail_system/templates/rspamd/milter_headers.conf

+ 1
- 0
README.md View File

@@ -0,0 +1 @@
1
+ansible role for debian buster setting up a mailserver with postfix, rspamd, dovecot and clamav and based on PostgreSQL Attention: user and domain administration (in PostgreSQL) is not covered here

+ 59
- 0
mail_system.yml View File

@@ -0,0 +1,59 @@
1
+# install a complete mail system with
2
+#
3
+#   - postfix
4
+#   - dovecot
5
+#   - clamav (with unofficial signatures)
6
+#   - rspamd (integrating clamav)
7
+#
8
+# not included here: list server, roundcube
9
+#
10
+# Please edit the host's config (inventory/host_vars/${hostname}):
11
+# Add a new dictionary 'mailserver':
12
+#
13
+# mailserver:
14
+#   postgresql:
15
+#     host: 127.0.0.1
16
+#     port: 5432
17
+#     dbname: mailserver
18
+#     username: mailserver
19
+#     password: !vault |
20
+#         $ANSIBLE_VAULT;1.1;AES256
21
+#         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
22
+#         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
23
+#         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
24
+#         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
25
+#         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
26
+#   postfix:
27
+#     overwrite_config: no
28
+#     mynetworks: "10.0.0.0/24 [2a01:XXXX:XXXX:XXXX::]/64"
29
+#   dovecot:
30
+#     auth_default_realm: mymaindomain.org
31
+#
32
+# (Use ansible-vault encrypt_string zo encrypt the password.)
33
+#
34
+# TODOs after running this playbook:
35
+#
36
+# Configure mail DNS:
37
+#
38
+#     - MX
39
+#     - PTR (IPv4 and IPv6)
40
+#
41
+# SPF, DMARC and DKIM DNS records should be created when adding a domain:
42
+#
43
+#     - SPF (IN TXT "v=spf1 mx" or more)
44
+#     - DMARC (_dmarc IN TXT "v=DMARC1; p=reject; rua=mailto:admin@mymaindomain.org; adkim=s; aspf=s;")
45
+#     - DKIM (rspamadm dkim_keygen -d mymaindomain.org -s 20190911 -b 4096;
46
+#             get the DNS entry and save the private key
47
+#
48
+# Please open the firewall: open or DNAT tcp ports 25, 143, 587, 4190 to the host (incoming)
49
+#
50
+# Replace the ssl certificates with signed ones.
51
+#
52
+# Users and domains can be added to the PostgreSQL tables;
53
+# code for that is not part of this playbook.
54
+
55
+- name: install mail_system
56
+  user: root
57
+  hosts: mail
58
+  roles:
59
+    - mail_system

+ 50
- 0
mail_system/tasks/clamav.yml View File

@@ -0,0 +1,50 @@
1
+# install clamav
2
+# we run freshclam (with daemons stopped) and then starting the daemons should work
3
+# (avoiding 'clamav-daemon not started: "ConditionPathExistsGlob=/var/lib/clamav/daily.{c[vl]d,inc} was not met"')
4
+
5
+- name: install clamav
6
+  apt:
7
+    name: "{{ packages }}"
8
+  vars:
9
+    packages:
10
+    - clamav
11
+    - clamav-daemon
12
+    - clamav-freshclam
13
+
14
+- name: stop clamav daemons
15
+  systemd:
16
+    name: "{{ item }}"
17
+    state: stopped
18
+  loop:
19
+    - clamav-freshclam
20
+    - clamav-daemon
21
+
22
+- name: run freshclam
23
+  shell: freshclam
24
+
25
+- name: start clamav daemons
26
+  systemd:
27
+    name: "{{ item }}"
28
+    state: started
29
+  loop:
30
+    - clamav-daemon
31
+    - clamav-freshclam
32
+
33
+- name: install clamav-unofficial-sigs, clamdscan
34
+  apt:
35
+    name: "{{ packages }}"
36
+  vars:
37
+    packages:
38
+    - clamav-unofficial-sigs
39
+    - clamdscan
40
+
41
+- name: set clamav BytecodeSecurity to Paranoid
42
+  lineinfile:
43
+    path: /etc/clamav/clamd.conf
44
+    regexp: '^BytecodeSecurity'
45
+    line: 'BytecodeSecurity Paranoid'
46
+
47
+- name: restart clamav-daemon
48
+  systemd:
49
+    name: clamav-daemon
50
+    state: restarted

+ 133
- 0
mail_system/tasks/database.yml View File

@@ -0,0 +1,133 @@
1
+- name: apt install python3-psycopg2
2
+  apt:
3
+    name: python3-psycopg2
4
+    state: present
5
+
6
+- name: database table domains
7
+  postgresql_table:
8
+    login_host: "{{ mailserver.postgresql.host }}"
9
+    port: "{{ mailserver.postgresql.port }}"
10
+    login_user: "{{ mailserver.postgresql.username }}"
11
+    login_password: "{{ mailserver.postgresql.password }}"
12
+    db: "{{ mailserver.postgresql.dbname }}"
13
+    ssl_mode: disable
14
+    name: domains
15
+    columns:
16
+    - id bigserial primary key
17
+    - name varchar(128) not null unique
18
+    - relay_transport text null
19
+
20
+- name: database table users
21
+  postgresql_table:
22
+    login_host: "{{ mailserver.postgresql.host }}"
23
+    port: "{{ mailserver.postgresql.port }}"
24
+    login_user: "{{ mailserver.postgresql.username }}"
25
+    login_password: "{{ mailserver.postgresql.password }}"
26
+    db: "{{ mailserver.postgresql.dbname }}"
27
+    ssl_mode: disable
28
+    name: users
29
+    columns:
30
+    - id BIGSERIAL PRIMARY KEY
31
+    - domain_id BIGINT references domains(id) on delete cascade
32
+    - username VARCHAR(128) NOT NULL
33
+    - realname VARCHAR(250) NOT NULL
34
+    - password VARCHAR(128) NOT NULL
35
+    - suspend_submission BOOL NOT NULL DEFAULT false
36
+    - suspend_imap_reason TEXT NULL
37
+    - quota_storage_bytes BIGINT NOT NULL DEFAULT 100000000000
38
+    - quota_inbox_messages INT NOT NULL DEFAULT 500000
39
+    - unique(domain_id, username)
40
+
41
+- name: database index users__domain_username
42
+  postgresql_idx:
43
+    login_host: "{{ mailserver.postgresql.host }}"
44
+    port: "{{ mailserver.postgresql.port }}"
45
+    login_user: "{{ mailserver.postgresql.username }}"
46
+    login_password: "{{ mailserver.postgresql.password }}"
47
+    db: "{{ mailserver.postgresql.dbname }}"
48
+    ssl_mode: disable
49
+    table: users
50
+    columns: domain_id, username
51
+    idxname: users__domain_username
52
+
53
+- name: database table aliases
54
+  postgresql_table:
55
+    login_host: "{{ mailserver.postgresql.host }}"
56
+    port: "{{ mailserver.postgresql.port }}"
57
+    login_user: "{{ mailserver.postgresql.username }}"
58
+    login_password: "{{ mailserver.postgresql.password }}"
59
+    db: "{{ mailserver.postgresql.dbname }}"
60
+    ssl_mode: disable
61
+    name: aliases
62
+    columns:
63
+    - id bigserial primary key
64
+    - alias_domain_id bigint references domains(id) on delete cascade
65
+    - alias varchar(250) not null unique
66
+    - forwardings varchar(250)[] not null
67
+    - t timestamp without time zone not null default now()
68
+    - comment text null
69
+
70
+- name: database index aliases__alias
71
+  postgresql_idx:
72
+    login_host: "{{ mailserver.postgresql.host }}"
73
+    port: "{{ mailserver.postgresql.port }}"
74
+    login_user: "{{ mailserver.postgresql.username }}"
75
+    login_password: "{{ mailserver.postgresql.password }}"
76
+    db: "{{ mailserver.postgresql.dbname }}"
77
+    ssl_mode: disable
78
+    table: aliases
79
+    columns: alias
80
+    idxname: aliases__alias
81
+
82
+- name: database table shared_folders
83
+  postgresql_table:
84
+    login_host: "{{ mailserver.postgresql.host }}"
85
+    port: "{{ mailserver.postgresql.port }}"
86
+    login_user: "{{ mailserver.postgresql.username }}"
87
+    login_password: "{{ mailserver.postgresql.password }}"
88
+    db: "{{ mailserver.postgresql.dbname }}"
89
+    ssl_mode: disable
90
+    name: shared_folders
91
+    columns:
92
+    - id bigserial primary key
93
+    - from_user varchar(128) not null
94
+    - to_user varchar(128) not null
95
+    - dummy char(1) DEFAULT '1'
96
+
97
+- name: database index shared_folders__from_to
98
+  postgresql_idx:
99
+    login_host: "{{ mailserver.postgresql.host }}"
100
+    port: "{{ mailserver.postgresql.port }}"
101
+    login_user: "{{ mailserver.postgresql.username }}"
102
+    login_password: "{{ mailserver.postgresql.password }}"
103
+    db: "{{ mailserver.postgresql.dbname }}"
104
+    ssl_mode: disable
105
+    table: shared_folders
106
+    columns: from_user, to_user
107
+    idxname: shared_folders__from_to
108
+
109
+- name: database table shared_folders_anyone
110
+  postgresql_table:
111
+    login_host: "{{ mailserver.postgresql.host }}"
112
+    port: "{{ mailserver.postgresql.port }}"
113
+    login_user: "{{ mailserver.postgresql.username }}"
114
+    login_password: "{{ mailserver.postgresql.password }}"
115
+    db: "{{ mailserver.postgresql.dbname }}"
116
+    ssl_mode: disable
117
+    name: shared_folders_anyone
118
+    columns:
119
+    - id bigserial primary key
120
+    - from_user varchar(128) not null
121
+    - dummy char(1) DEFAULT '1'
122
+
123
+- name: database index shared_folders_anyone__from
124
+  postgresql_idx:
125
+    login_host: "{{ mailserver.postgresql.host }}"
126
+    port: "{{ mailserver.postgresql.port }}"
127
+    login_user: "{{ mailserver.postgresql.username }}"
128
+    login_password: "{{ mailserver.postgresql.password }}"
129
+    db: "{{ mailserver.postgresql.dbname }}"
130
+    ssl_mode: disable
131
+    table: shared_folders_anyone
132
+    columns: from_user
133
+    idxname: shared_folders__from

+ 125
- 0
mail_system/tasks/dovecot.yml View File

@@ -0,0 +1,125 @@
1
+# here we assume that postfix.yml has run such that user 'mailstore' exists
2
+
3
+- name: install dovecot packages
4
+  apt:
5
+    name: dovecot-imapd,dovecot-lmtpd,dovecot-pgsql,dovecot-managesieved,dovecot-lucene
6
+    state: present
7
+
8
+- name: install dovecot config files
9
+  template:
10
+    src: "dovecot/{{ item }}"
11
+    dest: "/etc/dovecot/conf.d/{{ item }}"
12
+    owner: root
13
+    group: root
14
+    mode: 0644
15
+    force: yes
16
+  loop:
17
+    - 10-auth.conf
18
+    - auth-sql.conf.ext
19
+    - 10-mail.conf
20
+    - 10-master.conf
21
+    - 15-mailboxes.conf
22
+    - 20-lmtp.conf
23
+    - 20-imap.conf
24
+    - 90-sieve.conf
25
+    - 90-sieve-extprograms.conf
26
+    - 90-plugin.conf
27
+    - 90-acl.conf
28
+    - 90-quota.conf
29
+
30
+- name: install more dovecot config files
31
+  template:
32
+    src: "dovecot/{{ item }}"
33
+    dest: "/etc/dovecot/{{ item }}"
34
+    owner: root
35
+    group: dovecot
36
+    mode: 0640
37
+    force: yes
38
+  loop:
39
+    - dovecot.conf
40
+    - dovecot-sql.conf.ext
41
+    - dovecot-dict-sql.conf.ext
42
+
43
+- name: directories /etc/dovecot/sieve_before /etc/dovecot/sieve_after
44
+  file:
45
+    path: "/etc/dovecot/{{ item }}"
46
+    state: directory
47
+    owner: root
48
+    group: root
49
+    mode: 0755
50
+  loop:
51
+    - sieve_pipes
52
+    - sieve_filters
53
+    - sieve_execute
54
+    - sieve_before
55
+    - sieve_after
56
+
57
+- name: file /etc/dovecot/sieve_after/spam-to-folder.sieve
58
+  template:
59
+    src: dovecot/spam-to-folder.sieve
60
+    dest: /etc/dovecot/sieve_after/spam-to-folder.sieve
61
+    owner: root
62
+    group: root
63
+    mode: 0644
64
+    force: yes
65
+
66
+- name: files /etc/dovecot/sieve_pipes/*.sieve
67
+  template:
68
+    src: "dovecot/{{ item }}"
69
+    dest: "/etc/dovecot/sieve_pipes/{{ item }}"
70
+    owner: mailstore
71
+    group: mailstore
72
+    mode: 0600
73
+    force: yes
74
+  loop:
75
+    - learn-spam.sieve
76
+    - learn-ham.sieve
77
+
78
+- name: files /etc/dovecot/sieve_pipes/*.sh
79
+  template:
80
+    src: "dovecot/{{ item }}"
81
+    dest: "/etc/dovecot/sieve_pipes/{{ item }}"
82
+    owner: mailstore
83
+    group: mailstore
84
+    mode: 0700
85
+    force: yes
86
+  loop:
87
+    - rspamd-learn-spam.sh
88
+    - rspamd-learn-ham.sh
89
+
90
+- name: README files
91
+  template:
92
+    src: "dovecot/README_{{ item }}"
93
+    dest: "/etc/dovecot/sieve_{{ item }}/README"
94
+    owner: mailstore
95
+    group: mailstore
96
+    mode: 0600
97
+    force: yes
98
+  loop:
99
+    - filters
100
+    - execute
101
+    - before
102
+    - after
103
+
104
+- name: restart dovecot
105
+  systemd:
106
+    name: dovecot
107
+    state: restarted
108
+
109
+- name: compile sieve files
110
+  shell: "/usr/bin/sievec /etc/dovecot/{{ item }}"
111
+  loop:
112
+    - "sieve_after/spam-to-folder.sieve"
113
+    - "sieve_pipes/learn-spam.sieve"
114
+    - "sieve_pipes/learn-ham.sieve"
115
+
116
+- name: permissions of .svbin
117
+  file:
118
+    path: "/etc/dovecot/{{ item }}"
119
+    owner: mailstore
120
+    group: mailstore
121
+    mode: 0600
122
+  loop:
123
+    - "sieve_after/spam-to-folder.sieve"
124
+    - "sieve_pipes/learn-spam.svbin"
125
+    - "sieve_pipes/learn-ham.svbin"

+ 6
- 0
mail_system/tasks/main.yml View File

@@ -0,0 +1,6 @@
1
+- include: remove_other_mtas.yml
2
+- include: database.yml
3
+- include: postfix.yml
4
+- include: dovecot.yml
5
+- include: clamav.yml
6
+- include: rspamd.yml

+ 79
- 0
mail_system/tasks/postfix.yml View File

@@ -0,0 +1,79 @@
1
+- name: install postfix packages
2
+  apt:
3
+    name: postfix,postfix-pgsql,postfix-doc
4
+    state: present
5
+    update_cache: yes
6
+    install_recommends: no
7
+
8
+- name: divert /etc/postfix/main.cf
9
+  shell: dpkg-divert --add --rename --divert /etc/postfix/main.cf.orig /etc/postfix/main.cf
10
+
11
+- name: divert /etc/postfix/master.cf
12
+  shell: dpkg-divert --add --rename --divert /etc/postfix/master.cf.orig /etc/postfix/master.cf
13
+
14
+- name: group 'mailstore'
15
+  group:
16
+    name: mailstore
17
+    state: present
18
+    system: yes
19
+    gid: 5000
20
+
21
+- name: user 'mailstore'
22
+  user:
23
+    name: mailstore
24
+    group: mailstore
25
+    state: present
26
+    system: yes
27
+    uid: 5000
28
+    create_home: no
29
+    home: /srv/mailstore
30
+    password: '!'
31
+    password_lock: yes
32
+    comment: created by ansible
33
+
34
+- name: directories /srv/mailstore /srv/mailstore/role_specific
35
+  file:
36
+    path: "{{ item }}"
37
+    state: directory
38
+    owner: mailstore
39
+    group: mailstore
40
+    mode: 0755
41
+  loop:
42
+    - /srv/mailstore
43
+    - /srv/mailstore/role_specific
44
+    - /srv/mailstore/role_specific/roles
45
+
46
+- name: postfix configuration files
47
+  template:
48
+    src: "postfix/{{ item }}"
49
+    dest: "/etc/postfix/{{ item }}"
50
+    owner: root
51
+    group: root
52
+    mode: 0644
53
+    force: "{{ mailserver.postfix.overwrite_config }}"
54
+  loop:
55
+    - main.cf
56
+    - master.cf
57
+    - header_checks
58
+
59
+- name: postfix database queries
60
+  template:
61
+    src: "postfix/{{ item }}"
62
+    dest: "/etc/postfix/{{ item }}"
63
+    owner: root
64
+    group: root
65
+    mode: 0600
66
+    force: yes
67
+  loop:
68
+    - domains.cf
69
+    - mailboxes.cf
70
+    - aliases.cf
71
+    - email_existence_check.cf
72
+    - relay_domains.cf
73
+    - relay_recipient_maps.cf
74
+    - transport_maps.cf
75
+
76
+- name: restart postfix
77
+  systemd:
78
+    name: postfix
79
+    state: restarted

+ 10
- 0
mail_system/tasks/remove_other_mtas.yml View File

@@ -0,0 +1,10 @@
1
+- name: find all installed versions of mail-transport-agent except postfix
2
+  shell: aptitude search '~i~Pmail-transport-agent' | sed -e 's/^...\(.*\)/\1/' | awk '{ print $1 }' | grep -v postfix || /bin/true
3
+  register: mtas
4
+
5
+- name: purge MTAs other than postfix
6
+  apt:
7
+    name: "{{ item }}"
8
+    state: absent
9
+    purge: yes
10
+  loop: "{{ mtas.stdout_lines|list }}"

+ 81
- 0
mail_system/tasks/rspamd.yml View File

@@ -0,0 +1,81 @@
1
+- name: apt install rspamd
2
+  apt:
3
+    name: rspamd
4
+    state: present
5
+
6
+# postfix integration
7
+
8
+- name: postfix setting milter_mail_macros
9
+  lineinfile:
10
+    path: /etc/postfix/main.cf
11
+    regexp: '^milter_mail_macros='
12
+    line: 'milter_mail_macros=i {mail_addr} {client_addr} {client_name} {auth_authen}'
13
+    insertafter: '^# rspamd'
14
+
15
+- name: postfix setting milter_protocol
16
+  lineinfile:
17
+    path: /etc/postfix/main.cf
18
+    regexp: '^milter_protocol='
19
+    line: 'milter_protocol=6'
20
+    insertafter: '^# rspamd'
21
+
22
+- name: postfix setting non_smtpd_milters
23
+  lineinfile:
24
+    path: /etc/postfix/main.cf
25
+    regexp: '^non_smtpd_milters='
26
+    line: 'non_smtpd_milters=inet:127.0.0.1:11332'
27
+    insertafter: '^# rspamd'
28
+
29
+- name: postfix setting smtpd_milters
30
+  lineinfile:
31
+    path: /etc/postfix/main.cf
32
+    regexp: '^smtpd_milters='
33
+    line: 'smtpd_milters=inet:127.0.0.1:11332'
34
+    insertafter: '^# rspamd'
35
+
36
+- name: restart postfix
37
+  systemd:
38
+    name: postfix
39
+    state: restarted
40
+
41
+# rspamd configuration
42
+
43
+- name: rspamd configure extended_spam_headers true
44
+  template:
45
+    src: "rspamd/{{ item }}"
46
+    dest: "/etc/rspamd/override.d/{{ item }}"
47
+    owner: root
48
+    group: root
49
+    mode: 0644
50
+  loop:
51
+    - milter_headers.conf
52
+    - classifier-bayes.conf
53
+    - antivirus.conf
54
+
55
+# install dkim
56
+
57
+- name: mkdir /var/lib/rspamd/dkim
58
+  file:
59
+    path: /var/lib/rspamd/dkim
60
+    state: directory
61
+    owner: _rspamd
62
+    group: _rspamd
63
+    mode: '0755'
64
+
65
+- name: rspamd config dkim_signing.conf and arc.conf
66
+  template:
67
+    src: "rspamd/{{ item }}"
68
+    dest: "/etc/rspamd/local.d/{{ item }}"
69
+    owner: root
70
+    group: root
71
+    mode: 0644
72
+  loop:
73
+    - dkim_signing.conf
74
+    - arc.conf
75
+
76
+# restart rspamd
77
+
78
+- name: restart rspamd
79
+  systemd:
80
+    name: rspamd
81
+    state: restarted

+ 133
- 0
mail_system/templates/dovecot/10-auth.conf View File

@@ -0,0 +1,133 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## Authentication processes
6
+##
7
+
8
+# Disable LOGIN command and all other plaintext authentications unless
9
+# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
10
+# matches the local IP (ie. you're connecting from the same computer), the
11
+# connection is considered secure and plaintext authentication is allowed.
12
+# See also ssl=required setting.
13
+#disable_plaintext_auth = yes
14
+
15
+# Authentication cache size (e.g. 10M). 0 means it's disabled. Note that
16
+# bsdauth, PAM and vpopmail require cache_key to be set for caching to be used.
17
+#auth_cache_size = 0
18
+# Time to live for cached data. After TTL expires the cached record is no
19
+# longer used, *except* if the main database lookup returns internal failure.
20
+# We also try to handle password changes automatically: If user's previous
21
+# authentication was successful, but this one wasn't, the cache isn't used.
22
+# For now this works only with plaintext authentication.
23
+#auth_cache_ttl = 1 hour
24
+# TTL for negative hits (user not found, password mismatch).
25
+# 0 disables caching them completely.
26
+#auth_cache_negative_ttl = 1 hour
27
+
28
+# Space separated list of realms for SASL authentication mechanisms that need
29
+# them. You can leave it empty if you don't want to support multiple realms.
30
+# Many clients simply use the first one listed here, so keep the default realm
31
+# first.
32
+#auth_realms =
33
+
34
+# Default realm/domain to use if none was specified. This is used for both
35
+# SASL realms and appending @domain to username in plaintext logins.
36
+#auth_default_realm = 
37
+auth_default_realm = {{ mailserver.dovecot.auth_default_realm }}
38
+
39
+# List of allowed characters in username. If the user-given username contains
40
+# a character not listed in here, the login automatically fails. This is just
41
+# an extra check to make sure user can't exploit any potential quote escaping
42
+# vulnerabilities with SQL/LDAP databases. If you want to allow all characters,
43
+# set this value to empty.
44
+#auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@
45
+
46
+# Username character translations before it's looked up from databases. The
47
+# value contains series of from -> to characters. For example "#@/@" means
48
+# that '#' and '/' characters are translated to '@'.
49
+#auth_username_translation =
50
+
51
+# Username formatting before it's looked up from databases. You can use
52
+# the standard variables here, eg. %Lu would lowercase the username, %n would
53
+# drop away the domain if it was given, or "%n-AT-%d" would change the '@' into
54
+# "-AT-". This translation is done after auth_username_translation changes.
55
+#auth_username_format = %Lu
56
+
57
+# If you want to allow master users to log in by specifying the master
58
+# username within the normal username string (ie. not using SASL mechanism's
59
+# support for it), you can specify the separator character here. The format
60
+# is then <username><separator><master username>. UW-IMAP uses "*" as the
61
+# separator, so that could be a good choice.
62
+#auth_master_user_separator =
63
+
64
+# Username to use for users logging in with ANONYMOUS SASL mechanism
65
+#auth_anonymous_username = anonymous
66
+
67
+# Maximum number of dovecot-auth worker processes. They're used to execute
68
+# blocking passdb and userdb queries (eg. MySQL and PAM). They're
69
+# automatically created and destroyed as needed.
70
+#auth_worker_max_count = 30
71
+
72
+# Host name to use in GSSAPI principal names. The default is to use the
73
+# name returned by gethostname(). Use "$ALL" (with quotes) to allow all keytab
74
+# entries.
75
+#auth_gssapi_hostname =
76
+
77
+# Kerberos keytab to use for the GSSAPI mechanism. Will use the system
78
+# default (usually /etc/krb5.keytab) if not specified. You may need to change
79
+# the auth service to run as root to be able to read this file.
80
+#auth_krb5_keytab = 
81
+
82
+# Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon and
83
+# ntlm_auth helper. <doc/wiki/Authentication/Mechanisms/Winbind.txt>
84
+#auth_use_winbind = no
85
+
86
+# Path for Samba's ntlm_auth helper binary.
87
+#auth_winbind_helper_path = /usr/bin/ntlm_auth
88
+
89
+# Time to delay before replying to failed authentications.
90
+#auth_failure_delay = 2 secs
91
+
92
+# Require a valid SSL client certificate or the authentication fails.
93
+#auth_ssl_require_client_cert = no
94
+
95
+# Take the username from client's SSL certificate, using 
96
+# X509_NAME_get_text_by_NID() which returns the subject's DN's
97
+# CommonName. 
98
+#auth_ssl_username_from_cert = no
99
+
100
+# Space separated list of wanted authentication mechanisms:
101
+#   plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey
102
+#   gss-spnego
103
+# NOTE: See also disable_plaintext_auth setting.
104
+auth_mechanisms = plain
105
+
106
+##
107
+## Password and user databases
108
+##
109
+
110
+#
111
+# Password database is used to verify user's password (and nothing more).
112
+# You can have multiple passdbs and userdbs. This is useful if you want to
113
+# allow both system users (/etc/passwd) and virtual users to login without
114
+# duplicating the system users into virtual database.
115
+#
116
+# <doc/wiki/PasswordDatabase.txt>
117
+#
118
+# User database specifies where mails are located and what user/group IDs
119
+# own them. For single-UID configuration use "static" userdb.
120
+#
121
+# <doc/wiki/UserDatabase.txt>
122
+
123
+#!include auth-deny.conf.ext
124
+#!include auth-master.conf.ext
125
+
126
+#!include auth-system.conf.ext
127
+!include auth-sql.conf.ext
128
+#!include auth-ldap.conf.ext
129
+#!include auth-passwdfile.conf.ext
130
+#!include auth-checkpassword.conf.ext
131
+#!include auth-vpopmail.conf.ext
132
+#!include auth-static.conf.ext
133
+

+ 461
- 0
mail_system/templates/dovecot/10-mail.conf View File

@@ -0,0 +1,461 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## Mailbox locations and namespaces
6
+##
7
+
8
+# Location for users' mailboxes. The default is empty, which means that Dovecot
9
+# tries to find the mailboxes automatically. This won't work if the user
10
+# doesn't yet have any mail, so you should explicitly tell Dovecot the full
11
+# location.
12
+#
13
+# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)
14
+# isn't enough. You'll also need to tell Dovecot where the other mailboxes are
15
+# kept. This is called the "root mail directory", and it must be the first
16
+# path given in the mail_location setting.
17
+#
18
+# There are a few special variables you can use, eg.:
19
+#
20
+#   %u - username
21
+#   %n - user part in user@domain, same as %u if there's no domain
22
+#   %d - domain part in user@domain, empty if there's no domain
23
+#   %h - home directory
24
+#
25
+# See doc/wiki/Variables.txt for full list. Some examples:
26
+#
27
+#   mail_location = maildir:~/Maildir
28
+#   mail_location = mbox:~/mail:INBOX=/var/mail/%u
29
+#   mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
30
+#
31
+# <doc/wiki/MailLocation.txt>
32
+#
33
+#mail_location = mbox:~/mail:INBOX=/var/mail/%u
34
+mail_location = maildir:/srv/mailstore/%d/%n/Maildir:LAYOUT=fs
35
+
36
+# If you need to set multiple mailbox locations or want to change default
37
+# namespace settings, you can do it by defining namespace sections.
38
+#
39
+# You can have private, shared and public namespaces. Private namespaces
40
+# are for user's personal mails. Shared namespaces are for accessing other
41
+# users' mailboxes that have been shared. Public namespaces are for shared
42
+# mailboxes that are managed by sysadmin. If you create any shared or public
43
+# namespaces you'll typically want to enable ACL plugin also, otherwise all
44
+# users can access all the shared mailboxes, assuming they have permissions
45
+# on filesystem level to do so.
46
+namespace inbox {
47
+  # Namespace type: private, shared or public
48
+  #type = private
49
+
50
+  # Hierarchy separator to use. You should use the same separator for all
51
+  # namespaces or some clients get confused. '/' is usually a good one.
52
+  # The default however depends on the underlying mail storage format.
53
+  #separator = 
54
+  separator = /
55
+
56
+  # Prefix required to access this namespace. This needs to be different for
57
+  # all namespaces. For example "Public/".
58
+  #prefix = 
59
+
60
+  # Physical location of the mailbox. This is in same format as
61
+  # mail_location, which is also the default for it.
62
+  #location =
63
+
64
+  # There can be only one INBOX, and this setting defines which namespace
65
+  # has it.
66
+  inbox = yes
67
+
68
+  # If namespace is hidden, it's not advertised to clients via NAMESPACE
69
+  # extension. You'll most likely also want to set list=no. This is mostly
70
+  # useful when converting from another server with different namespaces which
71
+  # you want to deprecate but still keep working. For example you can create
72
+  # hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/".
73
+  #hidden = no
74
+
75
+  # Show the mailboxes under this namespace with LIST command. This makes the
76
+  # namespace visible for clients that don't support NAMESPACE extension.
77
+  # "children" value lists child mailboxes, but hides the namespace prefix.
78
+  #list = yes
79
+
80
+  # Namespace handles its own subscriptions. If set to "no", the parent
81
+  # namespace handles them (empty prefix should always have this as "yes")
82
+  #subscriptions = yes
83
+
84
+  # See 15-mailboxes.conf for definitions of special mailboxes.
85
+}
86
+
87
+# Example shared namespace configuration
88
+#namespace {
89
+  #type = shared
90
+  #separator = /
91
+
92
+  # Mailboxes are visible under "shared/user@domain/"
93
+  # %%n, %%d and %%u are expanded to the destination user.
94
+  #prefix = shared/%%u/
95
+
96
+  # Mail location for other users' mailboxes. Note that %variables and ~/
97
+  # expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the
98
+  # destination user's data.
99
+  #location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u
100
+
101
+  # Use the default namespace for saving subscriptions.
102
+  #subscriptions = no
103
+
104
+  # List the shared/ namespace only if there are visible shared mailboxes.
105
+  #list = children
106
+#}
107
+namespace shared {
108
+  type = shared
109
+  separator = /
110
+  prefix = shared/%%d/%%n/
111
+  # a) Per-user seen flags. Maildir indexes are shared. (INDEXPVT requires v2.2+)
112
+  #location = maildir:%%h/Maildir:INDEXPVT=~/Maildir/shared/%%d/%%n/
113
+  location = maildir:/srv/mailstore/%%d/%%n/Maildir:LAYOUT=fs:INDEXPVT=~/shared/%%d/%%n/
114
+  # b) Per-user seen flags. Maildir indexes are not shared. If users have direct filesystem level access to their mails, this is a safer option:
115
+  #location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u:INDEXPVT=~/Maildir/shared/%%u
116
+  subscriptions = no
117
+  list = yes
118
+  inbox = no
119
+}
120
+namespace roles {
121
+  type = shared
122
+  separator = /
123
+  prefix = roles/
124
+  # a) Per-user seen flags. Maildir indexes are shared. (INDEXPVT requires v2.2+)
125
+  #location = maildir:%%h/Maildir:INDEXPVT=~/Maildir/shared/%%d/%%n/
126
+  location = maildir:/srv/mailstore/role_specific/roles/Maildir:LAYOUT=fs:INDEXPVT=~/role_specific/roles/
127
+  # b) Per-user seen flags. Maildir indexes are not shared. If users have direct filesystem level access to their$
128
+  #location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u:INDEXPVT=~/Maildir/shared/%%u
129
+  subscriptions = no
130
+  list = yes
131
+  inbox = no
132
+}
133
+namespace virtual {
134
+  separator = /
135
+  prefix = virtual/
136
+  location = virtual:/srv/mailstore/%d/%n/Maildir_virtual
137
+}
138
+# Should shared INBOX be visible as "shared/user" or "shared/user/INBOX"?
139
+#mail_shared_explicit_inbox = no
140
+
141
+# System user and group used to access mails. If you use multiple, userdb
142
+# can override these by returning uid or gid fields. You can use either numbers
143
+# or names. <doc/wiki/UserIds.txt>
144
+#mail_uid =
145
+#mail_gid =
146
+mail_uid = mailstore
147
+mail_gid = mailstore
148
+
149
+# Group to enable temporarily for privileged operations. Currently this is
150
+# used only with INBOX when either its initial creation or dotlocking fails.
151
+# Typically this is set to "mail" to give access to /var/mail.
152
+mail_privileged_group = mail
153
+
154
+# Grant access to these supplementary groups for mail processes. Typically
155
+# these are used to set up access to shared mailboxes. Note that it may be
156
+# dangerous to set these if users can create symlinks (e.g. if "mail" group is
157
+# set here, ln -s /var/mail ~/mail/var could allow a user to delete others'
158
+# mailboxes, or ln -s /secret/shared/box ~/mail/mybox would allow reading it).
159
+#mail_access_groups =
160
+
161
+# Allow full filesystem access to clients. There's no access checks other than
162
+# what the operating system does for the active UID/GID. It works with both
163
+# maildir and mboxes, allowing you to prefix mailboxes names with eg. /path/
164
+# or ~user/.
165
+#mail_full_filesystem_access = no
166
+
167
+# Dictionary for key=value mailbox attributes. This is used for example by
168
+# URLAUTH and METADATA extensions.
169
+#mail_attribute_dict =
170
+
171
+# A comment or note that is associated with the server. This value is
172
+# accessible for authenticated users through the IMAP METADATA server
173
+# entry "/shared/comment". 
174
+#mail_server_comment = ""
175
+
176
+# Indicates a method for contacting the server administrator. According to
177
+# RFC 5464, this value MUST be a URI (e.g., a mailto: or tel: URL), but that
178
+# is currently not enforced. Use for example mailto:admin@example.com. This
179
+# value is accessible for authenticated users through the IMAP METADATA server
180
+# entry "/shared/admin".
181
+#mail_server_admin = 
182
+
183
+##
184
+## Mail processes
185
+##
186
+
187
+# Don't use mmap() at all. This is required if you store indexes to shared
188
+# filesystems (NFS or clustered filesystem).
189
+#mmap_disable = no
190
+
191
+# Rely on O_EXCL to work when creating dotlock files. NFS supports O_EXCL
192
+# since version 3, so this should be safe to use nowadays by default.
193
+#dotlock_use_excl = yes
194
+
195
+# When to use fsync() or fdatasync() calls:
196
+#   optimized (default): Whenever necessary to avoid losing important data
197
+#   always: Useful with e.g. NFS when write()s are delayed
198
+#   never: Never use it (best performance, but crashes can lose data)
199
+#mail_fsync = optimized
200
+
201
+# Locking method for index files. Alternatives are fcntl, flock and dotlock.
202
+# Dotlocking uses some tricks which may create more disk I/O than other locking
203
+# methods. NFS users: flock doesn't work, remember to change mmap_disable.
204
+#lock_method = fcntl
205
+
206
+# Directory where mails can be temporarily stored. Usually it's used only for
207
+# mails larger than >= 128 kB. It's used by various parts of Dovecot, for
208
+# example LDA/LMTP while delivering large mails or zlib plugin for keeping
209
+# uncompressed mails.
210
+#mail_temp_dir = /tmp
211
+
212
+# Valid UID range for users, defaults to 500 and above. This is mostly
213
+# to make sure that users can't log in as daemons or other system users.
214
+# Note that denying root logins is hardcoded to dovecot binary and can't
215
+# be done even if first_valid_uid is set to 0.
216
+#first_valid_uid = 500
217
+#last_valid_uid = 0
218
+
219
+# Valid GID range for users, defaults to non-root/wheel. Users having
220
+# non-valid GID as primary group ID aren't allowed to log in. If user
221
+# belongs to supplementary groups with non-valid GIDs, those groups are
222
+# not set.
223
+#first_valid_gid = 1
224
+#last_valid_gid = 0
225
+
226
+# Maximum allowed length for mail keyword name. It's only forced when trying
227
+# to create new keywords.
228
+#mail_max_keyword_length = 50
229
+
230
+# ':' separated list of directories under which chrooting is allowed for mail
231
+# processes (ie. /var/mail will allow chrooting to /var/mail/foo/bar too).
232
+# This setting doesn't affect login_chroot, mail_chroot or auth chroot
233
+# settings. If this setting is empty, "/./" in home dirs are ignored.
234
+# WARNING: Never add directories here which local users can modify, that
235
+# may lead to root exploit. Usually this should be done only if you don't
236
+# allow shell access for users. <doc/wiki/Chrooting.txt>
237
+#valid_chroot_dirs = 
238
+
239
+# Default chroot directory for mail processes. This can be overridden for
240
+# specific users in user database by giving /./ in user's home directory
241
+# (eg. /home/./user chroots into /home). Note that usually there is no real
242
+# need to do chrooting, Dovecot doesn't allow users to access files outside
243
+# their mail directory anyway. If your home directories are prefixed with
244
+# the chroot directory, append "/." to mail_chroot. <doc/wiki/Chrooting.txt>
245
+#mail_chroot = 
246
+
247
+# UNIX socket path to master authentication server to find users.
248
+# This is used by imap (for shared users) and lda.
249
+#auth_socket_path = /var/run/dovecot/auth-userdb
250
+
251
+# Directory where to look up mail plugins.
252
+#mail_plugin_dir = /usr/lib/dovecot/modules
253
+
254
+# Space separated list of plugins to load for all services. Plugins specific to
255
+# IMAP, LDA, etc. are added to this list in their own .conf files.
256
+#mail_plugins = 
257
+mail_plugins = acl quota fts fts_lucene virtual
258
+
259
+##
260
+## Mailbox handling optimizations
261
+##
262
+
263
+# Mailbox list indexes can be used to optimize IMAP STATUS commands. They are
264
+# also required for IMAP NOTIFY extension to be enabled.
265
+#mailbox_list_index = yes
266
+
267
+# Trust mailbox list index to be up-to-date. This reduces disk I/O at the cost
268
+# of potentially returning out-of-date results after e.g. server crashes.
269
+# The results will be automatically fixed once the folders are opened.
270
+#mailbox_list_index_very_dirty_syncs = yes
271
+
272
+# Should INBOX be kept up-to-date in the mailbox list index? By default it's
273
+# not, because most of the mailbox accesses will open INBOX anyway.
274
+#mailbox_list_index_include_inbox = no
275
+
276
+# The minimum number of mails in a mailbox before updates are done to cache
277
+# file. This allows optimizing Dovecot's behavior to do less disk writes at
278
+# the cost of more disk reads.
279
+#mail_cache_min_mail_count = 0
280
+
281
+# When IDLE command is running, mailbox is checked once in a while to see if
282
+# there are any new mails or other changes. This setting defines the minimum
283
+# time to wait between those checks. Dovecot can also use inotify and
284
+# kqueue to find out immediately when changes occur.
285
+#mailbox_idle_check_interval = 30 secs
286
+
287
+# Save mails with CR+LF instead of plain LF. This makes sending those mails
288
+# take less CPU, especially with sendfile() syscall with Linux and FreeBSD.
289
+# But it also creates a bit more disk I/O which may just make it slower.
290
+# Also note that if other software reads the mboxes/maildirs, they may handle
291
+# the extra CRs wrong and cause problems.
292
+#mail_save_crlf = no
293
+
294
+# Max number of mails to keep open and prefetch to memory. This only works with
295
+# some mailbox formats and/or operating systems.
296
+#mail_prefetch_count = 0
297
+
298
+# How often to scan for stale temporary files and delete them (0 = never).
299
+# These should exist only after Dovecot dies in the middle of saving mails.
300
+#mail_temp_scan_interval = 1w
301
+
302
+# How many slow mail accesses sorting can perform before it returns failure.
303
+# With IMAP the reply is: NO [LIMIT] Requested sort would have taken too long.
304
+# The untagged SORT reply is still returned, but it's likely not correct.
305
+#mail_sort_max_read_count = 0
306
+
307
+protocol !indexer-worker {
308
+  # If folder vsize calculation requires opening more than this many mails from
309
+  # disk (i.e. mail sizes aren't in cache already), return failure and finish
310
+  # the calculation via indexer process. Disabled by default. This setting must
311
+  # be 0 for indexer-worker processes.
312
+  #mail_vsize_bg_after_count = 0
313
+  mail_vsize_bg_after_count = 100
314
+}
315
+
316
+##
317
+## Maildir-specific settings
318
+##
319
+
320
+# By default LIST command returns all entries in maildir beginning with a dot.
321
+# Enabling this option makes Dovecot return only entries which are directories.
322
+# This is done by stat()ing each entry, so it causes more disk I/O.
323
+# (For systems setting struct dirent->d_type, this check is free and it's
324
+# done always regardless of this setting)
325
+#maildir_stat_dirs = no
326
+
327
+# When copying a message, do it with hard links whenever possible. This makes
328
+# the performance much better, and it's unlikely to have any side effects.
329
+#maildir_copy_with_hardlinks = yes
330
+
331
+# Assume Dovecot is the only MUA accessing Maildir: Scan cur/ directory only
332
+# when its mtime changes unexpectedly or when we can't find the mail otherwise.
333
+#maildir_very_dirty_syncs = no
334
+
335
+# If enabled, Dovecot doesn't use the S=<size> in the Maildir filenames for
336
+# getting the mail's physical size, except when recalculating Maildir++ quota.
337
+# This can be useful in systems where a lot of the Maildir filenames have a
338
+# broken size. The performance hit for enabling this is very small.
339
+#maildir_broken_filename_sizes = no
340
+
341
+# Always move mails from new/ directory to cur/, even when the \Recent flags
342
+# aren't being reset.
343
+#maildir_empty_new = no
344
+
345
+##
346
+## mbox-specific settings
347
+##
348
+
349
+# Which locking methods to use for locking mbox. There are four available:
350
+#  dotlock: Create <mailbox>.lock file. This is the oldest and most NFS-safe
351
+#           solution. If you want to use /var/mail/ like directory, the users
352
+#           will need write access to that directory.
353
+#  dotlock_try: Same as dotlock, but if it fails because of permissions or
354
+#               because there isn't enough disk space, just skip it.
355
+#  fcntl  : Use this if possible. Works with NFS too if lockd is used.
356
+#  flock  : May not exist in all systems. Doesn't work with NFS.
357
+#  lockf  : May not exist in all systems. Doesn't work with NFS.
358
+#
359
+# You can use multiple locking methods; if you do the order they're declared
360
+# in is important to avoid deadlocks if other MTAs/MUAs are using multiple
361
+# locking methods as well. Some operating systems don't allow using some of
362
+# them simultaneously.
363
+#
364
+# The Debian value for mbox_write_locks differs from upstream Dovecot. It is
365
+# changed to be compliant with Debian Policy (section 11.6) for NFS safety.
366
+#       Dovecot: mbox_write_locks = dotlock fcntl
367
+#       Debian:  mbox_write_locks = fcntl dotlock
368
+#
369
+#mbox_read_locks = fcntl
370
+#mbox_write_locks = fcntl dotlock
371
+
372
+# Maximum time to wait for lock (all of them) before aborting.
373
+#mbox_lock_timeout = 5 mins
374
+
375
+# If dotlock exists but the mailbox isn't modified in any way, override the
376
+# lock file after this much time.
377
+#mbox_dotlock_change_timeout = 2 mins
378
+
379
+# When mbox changes unexpectedly we have to fully read it to find out what
380
+# changed. If the mbox is large this can take a long time. Since the change
381
+# is usually just a newly appended mail, it'd be faster to simply read the
382
+# new mails. If this setting is enabled, Dovecot does this but still safely
383
+# fallbacks to re-reading the whole mbox file whenever something in mbox isn't
384
+# how it's expected to be. The only real downside to this setting is that if
385
+# some other MUA changes message flags, Dovecot doesn't notice it immediately.
386
+# Note that a full sync is done with SELECT, EXAMINE, EXPUNGE and CHECK 
387
+# commands.
388
+#mbox_dirty_syncs = yes
389
+
390
+# Like mbox_dirty_syncs, but don't do full syncs even with SELECT, EXAMINE,
391
+# EXPUNGE or CHECK commands. If this is set, mbox_dirty_syncs is ignored.
392
+#mbox_very_dirty_syncs = no
393
+
394
+# Delay writing mbox headers until doing a full write sync (EXPUNGE and CHECK
395
+# commands and when closing the mailbox). This is especially useful for POP3
396
+# where clients often delete all mails. The downside is that our changes
397
+# aren't immediately visible to other MUAs.
398
+#mbox_lazy_writes = yes
399
+
400
+# If mbox size is smaller than this (e.g. 100k), don't write index files.
401
+# If an index file already exists it's still read, just not updated.
402
+#mbox_min_index_size = 0
403
+
404
+# Mail header selection algorithm to use for MD5 POP3 UIDLs when
405
+# pop3_uidl_format=%m. For backwards compatibility we use apop3d inspired
406
+# algorithm, but it fails if the first Received: header isn't unique in all
407
+# mails. An alternative algorithm is "all" that selects all headers.
408
+#mbox_md5 = apop3d
409
+
410
+##
411
+## mdbox-specific settings
412
+##
413
+
414
+# Maximum dbox file size until it's rotated.
415
+#mdbox_rotate_size = 10M
416
+
417
+# Maximum dbox file age until it's rotated. Typically in days. Day begins
418
+# from midnight, so 1d = today, 2d = yesterday, etc. 0 = check disabled.
419
+#mdbox_rotate_interval = 0
420
+
421
+# When creating new mdbox files, immediately preallocate their size to
422
+# mdbox_rotate_size. This setting currently works only in Linux with some
423
+# filesystems (ext4, xfs).
424
+#mdbox_preallocate_space = no
425
+
426
+##
427
+## Mail attachments
428
+##
429
+
430
+# sdbox and mdbox support saving mail attachments to external files, which
431
+# also allows single instance storage for them. Other backends don't support
432
+# this for now.
433
+
434
+# Directory root where to store mail attachments. Disabled, if empty.
435
+#mail_attachment_dir =
436
+
437
+# Attachments smaller than this aren't saved externally. It's also possible to
438
+# write a plugin to disable saving specific attachments externally.
439
+#mail_attachment_min_size = 128k
440
+
441
+# Filesystem backend to use for saving attachments:
442
+#  posix : No SiS done by Dovecot (but this might help FS's own deduplication)
443
+#  sis posix : SiS with immediate byte-by-byte comparison during saving
444
+#  sis-queue posix : SiS with delayed comparison and deduplication
445
+#mail_attachment_fs = sis posix
446
+
447
+# Hash format to use in attachment filenames. You can add any text and
448
+# variables: %{md4}, %{md5}, %{sha1}, %{sha256}, %{sha512}, %{size}.
449
+# Variables can be truncated, e.g. %{sha256:80} returns only first 80 bits
450
+#mail_attachment_hash = %{sha1}
451
+
452
+# Settings to control adding $HasAttachment or $HasNoAttachment keywords.
453
+# By default, all MIME parts with Content-Disposition=attachment, or inlines
454
+# with filename parameter are consired attachments.
455
+#   add-flags-on-save - Add the keywords when saving new mails.
456
+#   content-type=type or !type - Include/exclude content type. Excluding will
457
+#     never consider the matched MIME part as attachment. Including will only
458
+#     negate an exclusion (e.g. content-type=!foo/* content-type=foo/bar).
459
+#   exclude-inlined - Exclude any Content-Disposition=inline MIME part.
460
+#mail_attachment_detection_options =
461
+

+ 154
- 0
mail_system/templates/dovecot/10-master.conf View File

@@ -0,0 +1,154 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+#default_process_limit = 100
5
+#default_client_limit = 1000
6
+
7
+# Default VSZ (virtual memory size) limit for service processes. This is mainly
8
+# intended to catch and kill processes that leak memory before they eat up
9
+# everything.
10
+#default_vsz_limit = 256M
11
+# for virtual mailbox 'all' we need more memory
12
+default_vsz_limit = 1G
13
+
14
+# Login user is internally used by login processes. This is the most untrusted
15
+# user in Dovecot system. It shouldn't have access to anything at all.
16
+#default_login_user = dovenull
17
+
18
+# Internal user is used by unprivileged processes. It should be separate from
19
+# login user, so that login processes can't disturb other processes.
20
+#default_internal_user = dovecot
21
+
22
+service imap-login {
23
+  inet_listener imap {
24
+    #port = 143
25
+  }
26
+  inet_listener imaps {
27
+    #port = 993
28
+    #ssl = yes
29
+  }
30
+
31
+  # Number of connections to handle before starting a new process. Typically
32
+  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0
33
+  # is faster. <doc/wiki/LoginProcess.txt>
34
+  #service_count = 1
35
+
36
+  # Number of processes to always keep waiting for more connections.
37
+  #process_min_avail = 0
38
+
39
+  # If you set service_count=0, you probably need to grow this.
40
+  #vsz_limit = $default_vsz_limit
41
+}
42
+
43
+service pop3-login {
44
+  inet_listener pop3 {
45
+    #port = 110
46
+  }
47
+  inet_listener pop3s {
48
+    #port = 995
49
+    #ssl = yes
50
+  }
51
+}
52
+
53
+service submission-login {
54
+  inet_listener submission {
55
+    #port = 587
56
+  }
57
+}
58
+
59
+service lmtp {
60
+  unix_listener /var/spool/postfix/private/dovecot-lmtp {
61
+    group = postfix
62
+    mode = 0600
63
+    user = postfix
64
+  }
65
+#  unix_listener lmtp {
66
+#    #mode = 0666
67
+#  }
68
+
69
+  # Create inet listener only if you can't use the above UNIX socket
70
+  #inet_listener lmtp {
71
+    # Avoid making LMTP visible for the entire internet
72
+    #address =
73
+    #port = 
74
+  #}
75
+}
76
+
77
+service imap {
78
+  # Most of the memory goes to mmap()ing files. You may need to increase this
79
+  # limit if you have huge mailboxes.
80
+  #vsz_limit = $default_vsz_limit
81
+
82
+  # Max. number of IMAP processes (connections)
83
+  #process_limit = 1024
84
+}
85
+
86
+service pop3 {
87
+  # Max. number of POP3 processes (connections)
88
+  #process_limit = 1024
89
+}
90
+
91
+service submission {
92
+  # Max. number of SMTP Submission processes (connections)
93
+  #process_limit = 1024
94
+}
95
+
96
+service auth {
97
+  # auth_socket_path points to this userdb socket by default. It's typically
98
+  # used by dovecot-lda, doveadm, possibly imap process, etc. Users that have
99
+  # full permissions to this socket are able to get a list of all usernames and
100
+  # get the results of everyone's userdb lookups.
101
+  #
102
+  # The default 0666 mode allows anyone to connect to the socket, but the
103
+  # userdb lookups will succeed only if the userdb returns an "uid" field that
104
+  # matches the caller process's UID. Also if caller's uid or gid matches the
105
+  # socket's uid or gid the lookup succeeds. Anything else causes a failure.
106
+  #
107
+  # To give the caller full permissions to lookup all users, set the mode to
108
+  # something else than 0666 and Dovecot lets the kernel enforce the
109
+  # permissions (e.g. 0777 allows everyone full permissions).
110
+  unix_listener auth-userdb {
111
+    #mode = 0666
112
+    #user = 
113
+    #group = 
114
+  }
115
+
116
+  # Postfix smtp-auth
117
+  #unix_listener /var/spool/postfix/private/auth {
118
+  #  mode = 0666
119
+  #}
120
+  unix_listener /var/spool/postfix/private/auth {
121
+    mode = 0660
122
+    user = postfix
123
+    group = postfix
124
+  }
125
+
126
+  # Auth process is run as this user.
127
+  #user = $default_internal_user
128
+}
129
+
130
+service auth-worker {
131
+  # Auth worker process is run as root by default, so that it can access
132
+  # /etc/shadow. If this isn't necessary, the user should be changed to
133
+  # $default_internal_user.
134
+  #user = root
135
+}
136
+
137
+service dict {
138
+  # If dict proxy is used, mail processes should have access to its socket.
139
+  # For example: mode=0660, group=vmail and global mail_access_groups=vmail
140
+  unix_listener dict {
141
+    mode = 0600
142
+    user = mailstore
143
+    group = mailstore
144
+  }
145
+}
146
+
147
+service quota-status {
148
+  executable = quota-status -p postfix
149
+  inet_listener {
150
+    port = 12480
151
+    # You can choose any port you want
152
+  }
153
+  client_limit = 1
154
+}

+ 86
- 0
mail_system/templates/dovecot/15-mailboxes.conf View File

@@ -0,0 +1,86 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## Mailbox definitions
6
+##
7
+
8
+# Each mailbox is specified in a separate mailbox section. The section name
9
+# specifies the mailbox name. If it has spaces, you can put the name
10
+# "in quotes". These sections can contain the following mailbox settings:
11
+#
12
+# auto:
13
+#   Indicates whether the mailbox with this name is automatically created
14
+#   implicitly when it is first accessed. The user can also be automatically
15
+#   subscribed to the mailbox after creation. The following values are
16
+#   defined for this setting:
17
+# 
18
+#     no        - Never created automatically.
19
+#     create    - Automatically created, but no automatic subscription.
20
+#     subscribe - Automatically created and subscribed.
21
+#  
22
+# special_use:
23
+#   A space-separated list of SPECIAL-USE flags (RFC 6154) to use for the
24
+#   mailbox. There are no validity checks, so you could specify anything
25
+#   you want in here, but it's not a good idea to use flags other than the
26
+#   standard ones specified in the RFC:
27
+#
28
+#     \All      - This (virtual) mailbox presents all messages in the
29
+#                 user's message store. 
30
+#     \Archive  - This mailbox is used to archive messages.
31
+#     \Drafts   - This mailbox is used to hold draft messages.
32
+#     \Flagged  - This (virtual) mailbox presents all messages in the
33
+#                 user's message store marked with the IMAP \Flagged flag.
34
+#     \Junk     - This mailbox is where messages deemed to be junk mail
35
+#                 are held.
36
+#     \Sent     - This mailbox is used to hold copies of messages that
37
+#                 have been sent.
38
+#     \Trash    - This mailbox is used to hold messages that have been
39
+#                 deleted.
40
+#
41
+# comment:
42
+#   Defines a default comment or note associated with the mailbox. This
43
+#   value is accessible through the IMAP METADATA mailbox entries
44
+#   "/shared/comment" and "/private/comment". Users with sufficient
45
+#   privileges can override the default value for entries with a custom
46
+#   value.
47
+
48
+# NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf.
49
+namespace inbox {
50
+  # These mailboxes are widely used and could perhaps be created automatically:
51
+  mailbox Drafts {
52
+    special_use = \Drafts
53
+  }
54
+  mailbox Junk {
55
+    auto = subscribe
56
+    special_use = \Junk
57
+    autoexpunge = 180d
58
+  }
59
+  mailbox Trash {
60
+    auto = subscribe
61
+    special_use = \Trash
62
+    autoexpunge = 180d
63
+  }
64
+
65
+  # For \Sent mailboxes there are two widely used names. We'll mark both of
66
+  # them as \Sent. User typically deletes one of them if duplicates are created.
67
+  mailbox Sent {
68
+    special_use = \Sent
69
+  }
70
+  mailbox "Sent Messages" {
71
+    special_use = \Sent
72
+  }
73
+
74
+  # If you have a virtual "All messages" mailbox:
75
+  #mailbox virtual/All {
76
+  #  special_use = \All
77
+  #  comment = All my messages
78
+  #}
79
+
80
+  # If you have a virtual "Flagged" mailbox:
81
+  #mailbox virtual/Flagged {
82
+  #  special_use = \Flagged
83
+  #  comment = All my flagged messages
84
+  #}
85
+}
86
+

+ 102
- 0
mail_system/templates/dovecot/20-imap.conf View File

@@ -0,0 +1,102 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## IMAP specific settings
6
+##
7
+
8
+# If nothing happens for this long while client is IDLEing, move the connection
9
+# to imap-hibernate process and close the old imap process. This saves memory,
10
+# because connections use very little memory in imap-hibernate process. The
11
+# downside is that recreating the imap process back uses some resources.
12
+#imap_hibernate_timeout = 0
13
+
14
+# Maximum IMAP command line length. Some clients generate very long command
15
+# lines with huge mailboxes, so you may need to raise this if you get
16
+# "Too long argument" or "IMAP command line too large" errors often.
17
+#imap_max_line_length = 64k
18
+
19
+# IMAP logout format string:
20
+#  %i - total number of bytes read from client
21
+#  %o - total number of bytes sent to client
22
+#  %{fetch_hdr_count} - Number of mails with mail header data sent to client
23
+#  %{fetch_hdr_bytes} - Number of bytes with mail header data sent to client
24
+#  %{fetch_body_count} - Number of mails with mail body data sent to client
25
+#  %{fetch_body_bytes} - Number of bytes with mail body data sent to client
26
+#  %{deleted} - Number of mails where client added \Deleted flag
27
+#  %{expunged} - Number of mails that client expunged, which does not
28
+#                include automatically expunged mails
29
+#  %{autoexpunged} - Number of mails that were automatically expunged after
30
+#                    client disconnected
31
+#  %{trashed} - Number of mails that client copied/moved to the
32
+#               special_use=\Trash mailbox.
33
+#  %{appended} - Number of mails saved during the session
34
+#imap_logout_format = in=%i out=%o deleted=%{deleted} expunged=%{expunged} \
35
+#  trashed=%{trashed} hdr_count=%{fetch_hdr_count} \
36
+#  hdr_bytes=%{fetch_hdr_bytes} body_count=%{fetch_body_count} \
37
+#  body_bytes=%{fetch_body_bytes}
38
+
39
+# Override the IMAP CAPABILITY response. If the value begins with '+',
40
+# add the given capabilities on top of the defaults (e.g. +XFOO XBAR).
41
+#imap_capability = 
42
+
43
+# How long to wait between "OK Still here" notifications when client is
44
+# IDLEing.
45
+#imap_idle_notify_interval = 2 mins
46
+
47
+# ID field names and values to send to clients. Using * as the value makes
48
+# Dovecot use the default value. The following fields have default values
49
+# currently: name, version, os, os-version, support-url, support-email.
50
+#imap_id_send = 
51
+
52
+# ID fields sent by client to log. * means everything.
53
+#imap_id_log =
54
+
55
+# Workarounds for various client bugs:
56
+#   delay-newmail:
57
+#     Send EXISTS/RECENT new mail notifications only when replying to NOOP
58
+#     and CHECK commands. Some clients ignore them otherwise, for example OSX
59
+#     Mail (<v2.1). Outlook Express breaks more badly though, without this it
60
+#     may show user "Message no longer in server" errors. Note that OE6 still
61
+#     breaks even with this workaround if synchronization is set to
62
+#     "Headers Only".
63
+#   tb-extra-mailbox-sep:
64
+#     Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
65
+#     adds extra '/' suffixes to mailbox names. This option causes Dovecot to
66
+#     ignore the extra '/' instead of treating it as invalid mailbox name.
67
+#   tb-lsub-flags:
68
+#     Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox).
69
+#     This makes Thunderbird realize they aren't selectable and show them
70
+#     greyed out, instead of only later giving "not selectable" popup error.
71
+#
72
+# The list is space-separated.
73
+#imap_client_workarounds = 
74
+
75
+# Host allowed in URLAUTH URLs sent by client. "*" allows all.
76
+#imap_urlauth_host =
77
+
78
+# Enable IMAP LITERAL- extension (replaces LITERAL+)
79
+#imap_literal_minus = no
80
+
81
+# What happens when FETCH fails due to some internal error:
82
+#   disconnect-immediately:
83
+#     The FETCH is aborted immediately and the IMAP client is disconnected.
84
+#   disconnect-after:
85
+#     The FETCH runs for all the requested mails returning as much data as
86
+#     possible. The client is finally disconnected without a tagged reply.
87
+#   no-after:
88
+#     Same as disconnect-after, but tagged NO reply is sent instead of
89
+#     disconnecting the client. If the client attempts to FETCH the same failed
90
+#     mail more than once, the client is disconnected. This is to avoid clients
91
+#     from going into infinite loops trying to FETCH a broken mail.
92
+#imap_fetch_failure = disconnect-immediately
93
+
94
+protocol imap {
95
+  # Space separated list of plugins to load (default is global mail_plugins).
96
+  mail_plugins = $mail_plugins imap_sieve imap_acl imap_quota
97
+
98
+  # Maximum number of IMAP connections allowed for a user from each IP address.
99
+  # NOTE: The username is compared case-sensitively.
100
+  #mail_max_userip_connections = 10
101
+}
102
+

+ 30
- 0
mail_system/templates/dovecot/20-lmtp.conf View File

@@ -0,0 +1,30 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## LMTP specific settings
6
+##
7
+
8
+# Support proxying to other LMTP/SMTP servers by performing passdb lookups.
9
+#lmtp_proxy = no
10
+
11
+# When recipient address includes the detail (e.g. user+detail), try to save
12
+# the mail to the detail mailbox. See also recipient_delimiter and
13
+# lda_mailbox_autocreate settings.
14
+#lmtp_save_to_detail_mailbox = no
15
+
16
+# Verify quota before replying to RCPT TO. This adds a small overhead.
17
+#lmtp_rcpt_check_quota = no
18
+
19
+# Which recipient address to use for Delivered-To: header and Received:
20
+# header. The default is "final", which is the same as the one given to
21
+# RCPT TO command. "original" uses the address given in RCPT TO's ORCPT
22
+# parameter, "none" uses nothing. Note that "none" is currently always used
23
+# when a mail has multiple recipients.
24
+#lmtp_hdr_delivery_address = final
25
+
26
+protocol lmtp {
27
+  # Space separated list of plugins to load (default is global mail_plugins).
28
+  #mail_plugins = $mail_plugins
29
+  mail_plugins = $mail_plugins sieve
30
+}

+ 24
- 0
mail_system/templates/dovecot/90-acl.conf View File

@@ -0,0 +1,24 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## Mailbox access control lists.
6
+##
7
+
8
+# vfile backend reads ACLs from "dovecot-acl" file from mail directory.
9
+# You can also optionally give a global ACL directory path where ACLs are
10
+# applied to all users' mailboxes. The global ACL directory contains
11
+# one file for each mailbox, eg. INBOX or sub.mailbox. cache_secs parameter
12
+# specifies how many seconds to wait between stat()ing dovecot-acl file
13
+# to see if it changed.
14
+plugin {
15
+  #acl = vfile:/etc/dovecot/global-acls:cache_secs=300
16
+  acl = vfile
17
+}
18
+
19
+# To let users LIST mailboxes shared by other users, Dovecot needs a
20
+# shared mailbox dictionary. For example:
21
+plugin {
22
+  #acl_shared_dict = file:/var/lib/dovecot/shared-mailboxes
23
+  acl_shared_dict = proxy::acl
24
+}

+ 18
- 0
mail_system/templates/dovecot/90-plugin.conf View File

@@ -0,0 +1,18 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## Plugin settings
6
+##
7
+
8
+# All wanted plugins must be listed in mail_plugins setting before any of the
9
+# settings take effect. See <doc/wiki/Plugins.txt> for list of plugins and
10
+# their configuration. Note that %variable expansion is done for all values.
11
+
12
+plugin {
13
+  fts = lucene
14
+  fts_lucene = whitespace_chars=@.
15
+  fts_autoindex=yes
16
+  fts_autoindex_exclude = \Junk
17
+  fts_autoindex_exclude2 = \Trash
18
+}

+ 107
- 0
mail_system/templates/dovecot/90-quota.conf View File

@@ -0,0 +1,107 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## Quota configuration.
6
+##
7
+
8
+# Note that you also have to enable quota plugin in mail_plugins setting.
9
+# <doc/wiki/Quota.txt>
10
+
11
+##
12
+## Quota limits
13
+##
14
+
15
+# Quota limits are set using "quota_rule" parameters. To get per-user quota
16
+# limits, you can set/override them by returning "quota_rule" extra field
17
+# from userdb. It's also possible to give mailbox-specific limits, for example
18
+# to give additional 100 MB when saving to Trash:
19
+
20
+plugin {
21
+  #quota_rule = *:storage=1G
22
+  #quota_rule2 = Trash:storage=+100M
23
+
24
+  # LDA/LMTP allows saving the last mail to bring user from under quota to
25
+  # over quota, if the quota doesn't grow too high. Default is to allow as
26
+  # long as quota will stay under 10% above the limit. Also allowed e.g. 10M.
27
+  #quota_grace = 10%%
28
+
29
+  # Quota plugin can also limit the maximum accepted mail size.
30
+  #quota_max_mail_size = 100M
31
+}
32
+
33
+##
34
+## Quota warnings
35
+##
36
+
37
+# You can execute a given command when user exceeds a specified quota limit.
38
+# Each quota root has separate limits. Only the command for the first
39
+# exceeded limit is executed, so put the highest limit first.
40
+# The commands are executed via script service by connecting to the named
41
+# UNIX socket (quota-warning below).
42
+# Note that % needs to be escaped as %%, otherwise "% " expands to empty.
43
+
44
+plugin {
45
+  #quota_warning = storage=95%% quota-warning 95 %u
46
+  #quota_warning2 = storage=80%% quota-warning 80 %u
47
+}
48
+
49
+# Example quota-warning service. The unix listener's permissions should be
50
+# set in a way that mail processes can connect to it. Below example assumes
51
+# that mail processes run as vmail user. If you use mode=0666, all system users
52
+# can generate quota warnings to anyone.
53
+#service quota-warning {
54
+#  executable = script /usr/local/bin/quota-warning.sh
55
+#  user = dovecot
56
+#  unix_listener quota-warning {
57
+#    user = vmail
58
+#  }
59
+#}
60
+
61
+##
62
+## Quota backends
63
+##
64
+
65
+# Multiple backends are supported:
66
+#   dirsize: Find and sum all the files found from mail directory.
67
+#            Extremely SLOW with Maildir. It'll eat your CPU and disk I/O.
68
+#   dict: Keep quota stored in dictionary (eg. SQL)
69
+#   maildir: Maildir++ quota
70
+#   fs: Read-only support for filesystem quota
71
+
72
+plugin {
73
+  #quota = dirsize:User quota
74
+  #quota = maildir:User quota
75
+  #quota = dict:User quota::proxy::quota
76
+  #quota = fs:User quota
77
+}
78
+
79
+# Multiple quota roots are also possible, for example this gives each user
80
+# their own 100MB quota and one shared 1GB quota within the domain:
81
+plugin {
82
+  #quota = dict:user::proxy::quota
83
+  #quota2 = dict:domain:%d:proxy::quota_domain
84
+  #quota_rule = *:storage=102400
85
+  #quota2_rule = *:storage=1048576
86
+}
87
+
88
+plugin {
89
+  # https://wiki2.dovecot.org/Quota
90
+  quota_grace = 10%%
91
+  quota_status_success = DUNNO
92
+  quota_status_nouser = DUNNO
93
+  quota_status_overquota = "552 5.2.2 Mailbox is full"
94
+  quota_exceeded_message = Quota exceeded, please reduce your your overall mail volume and/or the number of messages in your inbox.
95
+
96
+  # https://wiki2.dovecot.org/Quota/Configuration
97
+  # https://wiki2.dovecot.org/Quota/Count
98
+  quota = count:User quota
99
+  quota_rule = *:storage=80G
100
+  # ATTENTION: the following rule counts all messages in the mailbox, not just in the inbox
101
+  quota_rule2 = INBOX:messages=+500000
102
+  quota_rule3 = Trash:storage=+200M
103
+
104
+  # https://wiki2.dovecot.org/Quota/Count
105
+  # This is required - it uses "virtual sizes" rather than "physical sizes" for quota counting:
106
+  quota_vsizes = yes
107
+}

+ 49
- 0
mail_system/templates/dovecot/90-sieve-extprograms.conf View File

@@ -0,0 +1,49 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# Sieve Extprograms plugin configuration
5
+
6
+# Don't forget to add the sieve_extprograms plugin to the sieve_plugins setting.
7
+# Also enable the extensions you need (one or more of vnd.dovecot.pipe,
8
+# vnd.dovecot.filter and vnd.dovecot.execute) by adding these   to the
9
+# sieve_extensions or sieve_global_extensions settings. Restricting these
10
+# extensions to a global context using sieve_global_extensions is recommended.
11
+
12
+plugin {
13
+
14
+  # The directory where the program sockets are located for the
15
+  # vnd.dovecot.pipe, vnd.dovecot.filter and vnd.dovecot.execute extension
16
+  # respectively. The name of each unix socket contained in that directory
17
+  # directly maps to a program-name referenced from the Sieve script.
18
+  #sieve_pipe_socket_dir = sieve-pipe
19
+  #sieve_filter_socket_dir = sieve-filter
20
+  #sieve_execute_socket_dir = sieve-execute
21
+
22
+  # The directory where the scripts are located for direct execution by the
23
+  # vnd.dovecot.pipe, vnd.dovecot.filter and vnd.dovecot.execute extension
24
+  # respectively. The name of each script contained in that directory
25
+  # directly maps to a program-name referenced from the Sieve script.
26
+  #sieve_pipe_bin_dir = /usr/lib/dovecot/sieve-pipe
27
+  #sieve_filter_bin_dir = /usr/lib/dovecot/sieve-filter
28
+  #sieve_execute_bin_dir = /usr/lib/dovecot/sieve-execute
29
+  sieve_pipe_bin_dir = /etc/dovecot/sieve_pipes
30
+  sieve_filter_bin_dir = /etc/dovecot/sieve_filters
31
+  sieve_execute_bin_dir = /etc/dovecot/sieve_execute
32
+}
33
+
34
+# An example program service called 'do-something' to pipe messages to
35
+#service do-something {
36
+  # Define the executed script as parameter to the sieve service
37
+  #executable = script /usr/lib/dovecot/sieve-pipe/do-something.sh
38
+
39
+  # Use some unprivileged user for executing the program
40
+  #user = dovenull
41
+
42
+  # The unix socket located in the sieve_pipe_socket_dir (as defined in the 
43
+  # plugin {} section above)
44
+  #unix_listener sieve-pipe/do-something {
45
+    # LDA/LMTP must have access
46
+  #  user = vmail  
47
+  #  mode = 0600
48
+  #}
49
+#}

+ 234
- 0
mail_system/templates/dovecot/90-sieve.conf View File

@@ -0,0 +1,234 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+##
5
+## Settings for the Sieve interpreter
6
+##
7
+
8
+# Do not forget to enable the Sieve plugin in 15-lda.conf and 20-lmtp.conf
9
+# by adding it to the respective mail_plugins= settings.
10
+
11
+# The Sieve interpreter can retrieve Sieve scripts from several types of
12
+# locations. The default `file' location type is a local filesystem path
13
+# pointing to a Sieve script file or a directory containing multiple Sieve
14
+# script files. More complex setups can use other location types such as
15
+# `ldap' or `dict' to fetch Sieve scripts from remote databases.
16
+#
17
+# All settings that specify the location of one ore more Sieve scripts accept
18
+# the following syntax:
19
+#
20
+# location = [<type>:]path[;<option>[=<value>][;...]]
21
+#
22
+# If the type prefix is omitted, the script location type is 'file' and the 
23
+# location is interpreted as a local filesystem path pointing to a Sieve script
24
+# file or directory. Refer to Pigeonhole wiki or INSTALL file for more
25
+# information.
26
+
27
+plugin {
28
+  # The location of the user's main Sieve script or script storage. The LDA
29
+  # Sieve plugin uses this to find the active script for Sieve filtering at
30
+  # delivery. The "include" extension uses this location for retrieving
31
+  # :personal" scripts. This is also where the  ManageSieve service will store
32
+  # the user's scripts, if supported.
33
+  # 
34
+  # Currently only the 'file:' location type supports ManageSieve operation.
35
+  # Other location types like 'dict:' and 'ldap:' can currently only
36
+  # be used as a read-only script source ().
37
+  #
38
+  # For the 'file:' type: use the ';active=' parameter to specify where the
39
+  # active script symlink is located.
40
+  # For other types: use the ';name=' parameter to specify the name of the
41
+  # default/active script.
42
+  #sieve = file:~/sieve;active=~/.dovecot.sieve
43
+  sieve = file:/srv/mailstore/%d/%n/sieve;active=/srv/mailstore/%d/%n/.dovecot.sieve
44
+
45
+  # The default Sieve script when the user has none. This is the location of a
46
+  # global sieve script file, which gets executed ONLY if user's personal Sieve
47
+  # script doesn't exist. Be sure to pre-compile this script manually using the
48
+  # sievec command line tool if the binary is not stored in a global location.
49
+  # --> See sieve_before for executing scripts before the user's personal
50
+  #     script.
51
+  #sieve_default = /var/lib/dovecot/sieve/default.sieve
52
+
53
+  # The name by which the default Sieve script (as configured by the 
54
+  # sieve_default setting) is visible to the user through ManageSieve. 
55
+  #sieve_default_name = 
56
+
57
+  # Location for ":global" include scripts as used by the "include" extension.
58
+  #sieve_global =
59
+
60
+  # The location of a Sieve script that is run for any message that is about to
61
+  # be discarded; i.e., it is not delivered anywhere by the normal Sieve
62
+  # execution. This only happens when the "implicit keep" is canceled, by e.g.
63
+  # the "discard" action, and no actions that deliver the message are executed.
64
+  # This "discard script" can prevent discarding the message, by executing
65
+  # alternative actions. If the discard script does nothing, the message is
66
+    # still discarded as it would be when no discard script is configured.
67
+  #sieve_discard =
68
+
69
+  # Location Sieve of scripts that need to be executed before the user's
70
+  # personal script. If a 'file' location path points to a directory, all the 
71
+  # Sieve scripts contained therein (with the proper `.sieve' extension) are
72
+  # executed. The order of execution within that directory is determined by the
73
+  # file names, using a normal 8bit per-character comparison.
74
+  #
75
+  # Multiple script locations can be specified by appending an increasing number
76
+  # to the setting name. The Sieve scripts found from these locations are added
77
+  # to the script execution sequence in the specified order. Reading the
78
+  # numbered sieve_before settings stops at the first missing setting, so no
79
+  # numbers may be skipped.
80
+  #sieve_before = /var/lib/dovecot/sieve.d/
81
+  #sieve_before2 = ldap:/etc/sieve-ldap.conf;name=ldap-domain
82
+  #sieve_before3 = (etc...)
83
+  sieve_before = /etc/dovecot/sieve_before
84
+
85
+  # Identical to sieve_before, only the specified scripts are executed after the
86
+  # user's script (only when keep is still in effect!). Multiple script
87
+  # locations can be specified by appending an increasing number.
88
+  #sieve_after =
89
+  #sieve_after2 =
90
+  #sieve_after2 = (etc...)
91
+  sieve_after = /etc/dovecot/sieve_after
92
+
93
+  # Which Sieve language extensions are available to users. By default, all
94
+  # supported extensions are available, except for deprecated extensions or
95
+  # those that are still under development. Some system administrators may want
96
+  # to disable certain Sieve extensions or enable those that are not available
97
+  # by default. This setting can use '+' and '-' to specify differences relative
98
+  # to the default. For example `sieve_extensions = +imapflags' will enable the
99
+  # deprecated imapflags extension in addition to all extensions were already
100
+  # enabled by default.
101
+  #sieve_extensions = +notify +imapflags
102
+
103
+  # Which Sieve language extensions are ONLY available in global scripts. This
104
+  # can be used to restrict the use of certain Sieve extensions to administrator
105
+  # control, for instance when these extensions can cause security concerns.
106
+  # This setting has higher precedence than the `sieve_extensions' setting
107
+  # (above), meaning that the extensions enabled with this setting are never
108
+  # available to the user's personal script no matter what is specified for the
109
+  # `sieve_extensions' setting. The syntax of this setting is similar to the
110
+  # `sieve_extensions' setting, with the difference that extensions are
111
+  # enabled or disabled for exclusive use in global scripts. Currently, no
112
+  # extensions are marked as such by default.
113
+  #sieve_global_extensions =
114
+  sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.filter +vnd.dovecot.execute
115
+
116
+  # The Pigeonhole Sieve interpreter can have plugins of its own. Using this
117
+  # setting, the used plugins can be specified. Check the Dovecot wiki
118
+  # (wiki2.dovecot.org) or the pigeonhole website
119
+  # (http://pigeonhole.dovecot.org) for available plugins.
120
+  # The sieve_extprograms plugin is included in this release.
121
+  #sieve_plugins =
122
+  sieve_plugins = sieve_imapsieve sieve_extprograms
123
+
124
+  # The separator that is expected between the :user and :detail
125
+  # address parts introduced by the subaddress extension. This may
126
+  # also be a sequence of characters (e.g. '--'). The current
127
+  # implementation looks for the separator from the left of the
128
+  # localpart and uses the first one encountered. The :user part is
129
+  # left of the separator and the :detail part is right. This setting
130
+  # is also used by Dovecot's LMTP service.
131
+  #recipient_delimiter = +
132
+
133
+  # The maximum size of a Sieve script. The compiler will refuse to compile any
134
+  # script larger than this limit. If set to 0, no limit on the script size is
135
+  # enforced.
136
+  #sieve_max_script_size = 1M
137
+
138
+  # The maximum number of actions that can be performed during a single script
139
+  # execution. If set to 0, no limit on the total number of actions is enforced.
140
+  #sieve_max_actions = 32
141
+
142
+  # The maximum number of redirect actions that can be performed during a single
143
+  # script execution. If set to 0, no redirect actions are allowed.
144
+  #sieve_max_redirects = 4
145
+
146
+  # The maximum number of personal Sieve scripts a single user can have. If set
147
+  # to 0, no limit on the number of scripts is enforced.
148
+  # (Currently only relevant for ManageSieve)
149
+  #sieve_quota_max_scripts = 0
150
+
151
+  # The maximum amount of disk storage a single user's scripts may occupy. If
152
+  # set to 0, no limit on the used amount of disk storage is enforced.
153
+  # (Currently only relevant for ManageSieve)
154
+  #sieve_quota_max_storage = 0
155
+
156
+  # The primary e-mail address for the user. This is used as a default when no
157
+  # other appropriate address is available for sending messages. If this setting
158
+  # is not configured, either the postmaster or null "<>" address is used as a
159
+  # sender, depending on the action involved. This setting is important when
160
+  # there is no message envelope to extract addresses from, such as when the
161
+  # script is executed in IMAP.
162
+  #sieve_user_email =
163
+
164
+  # The path to the file where the user log is written. If not configured, a
165
+  # default location is used. If the main user's personal Sieve (as configured
166
+  # with sieve=) is a file, the logfile is set to <filename>.log by default. If
167
+  # it is not a file, the default user log file is ~/.dovecot.sieve.log.
168
+  #sieve_user_log =
169
+
170
+  # Specifies what envelope sender address is used for redirected messages.
171
+  # The following values are supported for this setting:
172
+  #
173
+  #   "sender"         - The sender address is used (default).
174
+  #   "recipient"      - The final recipient address is used.
175
+  #   "orig_recipient" - The original recipient is used.
176
+  #   "user_email"     - The user's primary address is used. This is
177
+  #                      configured with the "sieve_user_email" setting. If
178
+  #                      that setting is unconfigured, "user_mail" is equal to
179
+  #                      "recipient".
180
+  #   "postmaster"     - The postmaster_address configured for the LDA.
181
+  #   "<user@domain>"  - Redirected messages are always sent from user@domain.
182
+  #                      The angle brackets are mandatory. The null "<>" address
183
+  #                      is also supported.
184
+  #
185
+  # This setting is ignored when the envelope sender is "<>". In that case the
186
+  # sender of the redirected message is also always "<>".
187
+  #sieve_redirect_envelope_from = sender
188
+
189
+  ## TRACE DEBUGGING
190
+  # Trace debugging provides detailed insight in the operations performed by
191
+  # the Sieve script. These settings apply to both the LDA Sieve plugin and the
192
+  # IMAPSIEVE plugin. 
193
+  #
194
+  # WARNING: On a busy server, this functionality can quickly fill up the trace
195
+  # directory with a lot of trace files. Enable this only temporarily and as
196
+  # selective as possible.
197
+  
198
+  # The directory where trace files are written. Trace debugging is disabled if
199
+  # this setting is not configured or if the directory does not exist. If the 
200
+  # path is relative or it starts with "~/" it is interpreted relative to the
201
+  # current user's home directory.
202
+  #sieve_trace_dir =
203
+  
204
+  # The verbosity level of the trace messages. Trace debugging is disabled if
205
+  # this setting is not configured. Possible values are:
206
+  #
207
+  #   "actions"        - Only print executed action commands, like keep,
208
+  #                      fileinto, reject and redirect.
209
+  #   "commands"       - Print any executed command, excluding test commands.
210
+  #   "tests"          - Print all executed commands and performed tests.
211
+  #   "matching"       - Print all executed commands, performed tests and the
212
+  #                      values matched in those tests.
213
+  #sieve_trace_level =
214
+  
215
+  # Enables highly verbose debugging messages that are usually only useful for
216
+  # developers.
217
+  #sieve_trace_debug = no
218
+  
219
+  # Enables showing byte code addresses in the trace output, rather than only
220
+  # the source line numbers.
221
+  #sieve_trace_addresses = no 
222
+
223
+
224
+  # From elsewhere to Junk folder
225
+  imapsieve_mailbox1_name = Junk
226
+  imapsieve_mailbox1_causes = COPY
227
+  imapsieve_mailbox1_before = file:/etc/dovecot/sieve_pipes/learn-spam.sieve
228
+
229
+  # From Junk folder to elsewhere
230
+  imapsieve_mailbox2_name = *
231
+  imapsieve_mailbox2_from = Junk
232
+  imapsieve_mailbox2_causes = COPY
233
+  imapsieve_mailbox2_before = file:/etc/dovecot/sieve_pipes/learn-ham.sieve
234
+}

+ 3
- 0
mail_system/templates/dovecot/README_after View File

@@ -0,0 +1,3 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+See sieve_before/README; sieve filters in this directory are run after the user's scripts.

+ 40
- 0
mail_system/templates/dovecot/README_before View File

@@ -0,0 +1,40 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+Sieve scripts that will be run before user scripts.
5
+
6
+Don't forget to compile the script with
7
+
8
+  sievec /etc/dovecot/sieve_before/{name}.sieve
9
+
10
+and
11
+
12
+  chown mailstore: /etc/dovecot/sieve_before/{name}.*
13
+
14
+
15
+You may use regular Sieve extensions, but also Dovecot-specific Sieve extensions,
16
+cf. https://wiki2.dovecot.org/Pigeonhole/Sieve .
17
+
18
+(Note: We made vnd.dovecot.{pipe,filter,execute} available only in the global context,
19
+they cannot be used by users.)
20
+
21
+
22
+Example:
23
+
24
+require ["vnd.dovecot.filter", "vnd.dovecot.execute", "variables", "envelope", "subaddress"];
25
+
26
+if execute :output "out" :pipe "copy_to_matrix" {
27
+  filter "test" "${out}";
28
+}
29
+
30
+if envelope :matches :detail "to" "*" {
31
+  set "x" "${1}";
32
+}
33
+
34
+filter "test" "${x}";
35
+
36
+if envelope :matches :user "to" "*" {
37
+  set "y" "${1}";
38
+}
39
+
40
+filter "test" "${y}";

+ 13
- 0
mail_system/templates/dovecot/README_execute View File

@@ -0,0 +1,13 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+Execute is useful for conditions
5
+
6
+Take care to not output a newline after the result!
7
+
8
+Example:
9
+
10
+#!/bin/bash
11
+d=$(/bin/date +%s)
12
+echo -n $d
13
+exit 0

+ 15
- 0
mail_system/templates/dovecot/README_filters View File

@@ -0,0 +1,15 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+A filter accepts a mail as input, modifies it and outputs the result.
5
+
6
+Note: You cannot have side-effects like putting something into /tmp.
7
+
8
+
9
+Example:
10
+
11
+#!/bin/bash
12
+
13
+echo "X-Test: $(date) $1"
14
+cat
15
+

+ 42
- 0
mail_system/templates/dovecot/auth-sql.conf.ext View File

@@ -0,0 +1,42 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# Authentication for SQL users. Included from 10-auth.conf.
5
+#
6
+# <doc/wiki/AuthDatabase.SQL.txt>
7
+
8
+passdb {
9
+  driver = sql
10
+
11
+  # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
12
+  args = /etc/dovecot/dovecot-sql.conf.ext
13
+}
14
+
15
+# "prefetch" user database means that the passdb already provided the
16
+# needed information and there's no need to do a separate userdb lookup.
17
+# <doc/wiki/UserDatabase.Prefetch.txt>
18
+#userdb {
19
+#  driver = prefetch
20
+#}
21
+
22
+userdb {
23
+  driver = sql
24
+  args = /etc/dovecot/dovecot-sql.conf.ext
25
+}
26
+# using the static driver will cause the iterate_query
27
+# in /etc/dovecot/dovecot-sql.conf.ext
28
+# to fail (e.g. for 'doveadm mailbox list -A'),
29
+# so we also fetch the userdb via sql, even if this would be faster:
30
+#userdb {
31
+#  driver = static
32
+#  args = uid=mailstore gid=mailstore home=/srv/mailstore/%d/%n
33
+#}
34
+
35
+
36
+# If you don't have any user-specific settings, you can avoid the user_query
37
+# by using userdb static instead of userdb sql, for example:
38
+# <doc/wiki/UserDatabase.Static.txt>
39
+#userdb {
40
+  #driver = static
41
+  #args = uid=vmail gid=vmail home=/var/vmail/%u
42
+#}

+ 65
- 0
mail_system/templates/dovecot/dovecot-dict-sql.conf.ext View File

@@ -0,0 +1,65 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# This file is commonly accessed via dict {} section in dovecot.conf
5
+
6
+connect = host={{ mailserver.postgresql.host }} port={{ mailserver.postgresql.port }} dbname={{ mailserver.postgresql.dbname }} user={{ mailserver.postgresql.username }} password={{ mailserver.postgresql.password }}
7
+
8
+# CREATE TABLE quota (
9
+#   username varchar(100) not null,
10
+#   bytes bigint not null default 0,
11
+#   messages integer not null default 0,
12
+#   primary key (username)
13
+# );
14
+
15
+#map {
16
+#  pattern = priv/quota/storage
17
+#  table = quota
18
+#  username_field = username
19
+#  value_field = bytes
20
+#}
21
+#map {
22
+#  pattern = priv/quota/messages
23
+#  table = quota
24
+#  username_field = username
25
+#  value_field = messages
26
+#}
27
+
28
+# CREATE TABLE expires (
29
+#   username varchar(100) not null,
30
+#   mailbox varchar(255) not null,
31
+#   expire_stamp integer not null,
32
+#   primary key (username, mailbox)
33
+# );
34
+
35
+#map {
36
+#  pattern = shared/expire/$user/$mailbox
37
+#  table = expires
38
+#  value_field = expire_stamp
39
+#
40
+#  fields {
41
+#    username = $user
42
+#    mailbox = $mailbox
43
+#  }
44
+#}
45
+
46
+map {
47
+  pattern = shared/shared-boxes/user/$to/$from
48
+  table = shared_folders
49
+  value_field = dummy
50
+
51
+  fields {
52
+    from_user = $from
53
+    to_user = $to
54
+  }
55
+}
56
+
57
+map {
58
+  pattern = shared/shared-boxes/anyone/$from
59
+  table = shared_folders_anyone
60
+  value_field = dummy
61
+
62
+  fields {
63
+    from_user = $from
64
+  }
65
+}

+ 174
- 0
mail_system/templates/dovecot/dovecot-sql.conf.ext View File

@@ -0,0 +1,174 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# This file is commonly accessed via passdb {} or userdb {} section in
5
+# conf.d/auth-sql.conf.ext
6
+
7
+# This file is opened as root, so it should be owned by root and mode 0600.
8
+#
9
+# http://wiki2.dovecot.org/AuthDatabase/SQL
10
+#
11
+# For the sql passdb module, you'll need a database with a table that
12
+# contains fields for at least the username and password. If you want to
13
+# use the user@domain syntax, you might want to have a separate domain
14
+# field as well.
15
+#
16
+# If your users all have the same uig/gid, and have predictable home
17
+# directories, you can use the static userdb module to generate the home
18
+# dir based on the username and domain. In this case, you won't need fields
19
+# for home, uid, or gid in the database.
20
+#
21
+# If you prefer to use the sql userdb module, you'll want to add fields
22
+# for home, uid, and gid. Here is an example table:
23
+#
24
+# CREATE TABLE users (
25
+#     username VARCHAR(128) NOT NULL,
26
+#     domain VARCHAR(128) NOT NULL,
27
+#     password VARCHAR(64) NOT NULL,
28
+#     home VARCHAR(255) NOT NULL,
29
+#     uid INTEGER NOT NULL,
30
+#     gid INTEGER NOT NULL,
31
+#     active CHAR(1) DEFAULT 'Y' NOT NULL
32
+# );
33
+
34
+# Database driver: mysql, pgsql, sqlite
35
+#driver = 
36
+
37
+# Database connection string. This is driver-specific setting.
38
+#
39
+# HA / round-robin load-balancing is supported by giving multiple host
40
+# settings, like: host=sql1.host.org host=sql2.host.org
41
+#
42
+# pgsql:
43
+#   For available options, see the PostgreSQL documentation for the
44
+#   PQconnectdb function of libpq.
45
+#   Use maxconns=n (default 5) to change how many connections Dovecot can
46
+#   create to pgsql.
47
+#
48
+# mysql:
49
+#   Basic options emulate PostgreSQL option names:
50
+#     host, port, user, password, dbname
51
+#
52
+#   But also adds some new settings:
53
+#     client_flags           - See MySQL manual
54
+#     connect_timeout        - Connect timeout in seconds (default: 5)
55
+#     read_timeout           - Read timeout in seconds (default: 30)
56
+#     write_timeout          - Write timeout in seconds (default: 30)
57
+#     ssl_ca, ssl_ca_path    - Set either one or both to enable SSL
58
+#     ssl_cert, ssl_key      - For sending client-side certificates to server
59
+#     ssl_cipher             - Set minimum allowed cipher security (default: HIGH)
60
+#     ssl_verify_server_cert - Verify that the name in the server SSL certificate
61
+#                              matches the host (default: no)
62
+#     option_file            - Read options from the given file instead of
63
+#                              the default my.cnf location
64
+#     option_group           - Read options from the given group (default: client)
65
+# 
66
+#   You can connect to UNIX sockets by using host: host=/var/run/mysql.sock
67
+#   Note that currently you can't use spaces in parameters.
68
+#
69
+# sqlite:
70
+#   The path to the database file.
71
+#
72
+# Examples:
73
+#   connect = host=192.168.1.1 dbname=users
74
+#   connect = host=sql.example.com dbname=virtual user=virtual password=blarg
75
+#   connect = /etc/dovecot/authdb.sqlite
76
+#
77
+#connect =
78
+
79
+# Default password scheme.
80
+#
81
+# List of supported schemes is in
82
+# http://wiki2.dovecot.org/Authentication/PasswordSchemes
83
+#
84
+#default_pass_scheme = MD5
85
+
86
+# passdb query to retrieve the password. It can return fields:
87
+#   password - The user's password. This field must be returned.
88
+#   user - user@domain from the database. Needed with case-insensitive lookups.
89
+#   username and domain - An alternative way to represent the "user" field.
90
+#
91
+# The "user" field is often necessary with case-insensitive lookups to avoid
92
+# e.g. "name" and "nAme" logins creating two different mail directories. If
93
+# your user and domain names are in separate fields, you can return "username"
94
+# and "domain" fields instead of "user".
95
+#
96
+# The query can also return other fields which have a special meaning, see
97
+# http://wiki2.dovecot.org/PasswordDatabase/ExtraFields
98
+#
99
+# Commonly used available substitutions (see http://wiki2.dovecot.org/Variables
100
+# for full list):
101
+#   %u = entire user@domain
102
+#   %n = user part of user@domain
103
+#   %d = domain part of user@domain
104
+# 
105
+# Note that these can be used only as input to SQL query. If the query outputs
106
+# any of these substitutions, they're not touched. Otherwise it would be
107
+# difficult to have eg. usernames containing '%' characters.
108
+#
109
+# Example:
110
+#   password_query = SELECT userid AS user, pw AS password \
111
+#     FROM users WHERE userid = '%u' AND active = 'Y'
112
+#
113
+#password_query = \
114
+#  SELECT username, domain, password \
115
+#  FROM users WHERE username = '%n' AND domain = '%d'
116
+
117
+# userdb query to retrieve the user information. It can return fields:
118
+#   uid - System UID (overrides mail_uid setting)
119
+#   gid - System GID (overrides mail_gid setting)
120
+#   home - Home directory
121
+#   mail - Mail location (overrides mail_location setting)
122
+#
123
+# None of these are strictly required. If you use a single UID and GID, and
124
+# home or mail directory fits to a template string, you could use userdb static
125
+# instead. For a list of all fields that can be returned, see
126
+# http://wiki2.dovecot.org/UserDatabase/ExtraFields
127
+#
128
+# Examples:
129
+#   user_query = SELECT home, uid, gid FROM users WHERE userid = '%u'
130
+#   user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u'
131
+#   user_query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%u'
132
+#
133
+#user_query = \
134
+#  SELECT home, uid, gid \
135
+#  FROM users WHERE username = '%n' AND domain = '%d'
136
+
137
+# If you wish to avoid two SQL lookups (passdb + userdb), you can use
138
+# userdb prefetch instead of userdb sql in dovecot.conf. In that case you'll
139
+# also have to return userdb fields in password_query prefixed with "userdb_"
140
+# string. For example:
141
+#password_query = \
142
+#  SELECT userid AS user, password, \
143
+#    home AS userdb_home, uid AS userdb_uid, gid AS userdb_gid \
144
+#  FROM users WHERE userid = '%u'
145
+
146
+# Query to get a list of all usernames.
147
+#iterate_query = SELECT username AS user FROM users
148
+
149
+driver = pgsql
150
+connect = host={{ mailserver.postgresql.host }} port={{ mailserver.postgresql.port }} dbname={{ mailserver.postgresql.dbname }} user={{ mailserver.postgresql.username }} password={{ mailserver.postgresql.password }}
151
+default_pass_scheme = PBKDF2
152
+password_query = \
153
+  SELECT \
154
+    users.username as user, \
155
+    domains.name as domain, \
156
+    password, \
157
+    suspend_imap_reason as nologin \
158
+  FROM users JOIN domains ON users.domain_id=domains.id \
159
+  WHERE users.username = split_part('%u', '@', 1) AND domains.name = split_part('%u', '@', 2);
160
+# iterate_query is used by doveadm sync, doveadm backup etc.
161
+iterate_query = \
162
+  SELECT \
163
+    users.username as username, \
164
+    domains.name as domain \
165
+  FROM users JOIN domains ON users.domain_id=domains.id \
166
+  ORDER BY 2,1;
167
+user_query = \
168
+  SELECT \
169
+    '/srv/mailstore/' || domains.name || '/' || users.username || '/Maildir/' as home, \
170
+    'mailstore' as uid, 'mailstore' as gid, \
171
+    '*:bytes=' || quota_storage_bytes as quota_rule, \
172
+    'INBOX:messages=+' || quota_inbox_messages as quota_rule2 \
173
+  FROM users JOIN domains ON users.domain_id=domains.id \
174
+  WHERE users.username = '%n' AND domains.name = '%d';

+ 107
- 0
mail_system/templates/dovecot/dovecot.conf View File

@@ -0,0 +1,107 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+## Dovecot configuration file
5
+
6
+# If you're in a hurry, see http://wiki2.dovecot.org/QuickConfiguration
7
+
8
+# "doveconf -n" command gives a clean output of the changed settings. Use it
9
+# instead of copy&pasting files when posting to the Dovecot mailing list.
10
+
11
+# '#' character and everything after it is treated as comments. Extra spaces
12
+# and tabs are ignored. If you want to use either of these explicitly, put the
13
+# value inside quotes, eg.: key = "# char and trailing whitespace  "
14
+
15
+# Most (but not all) settings can be overridden by different protocols and/or
16
+# source/destination IPs by placing the settings inside sections, for example:
17
+# protocol imap { }, local 127.0.0.1 { }, remote 10.0.0.0/8 { }
18
+
19
+# Default values are shown for each setting, it's not required to uncomment
20
+# those. These are exceptions to this though: No sections (e.g. namespace {})
21
+# or plugin settings are added by default, they're listed only as examples.
22
+# Paths are also just examples with the real defaults being based on configure
23
+# options. The paths listed here are for configure --prefix=/usr
24
+# --sysconfdir=/etc --localstatedir=/var
25
+
26
+# Enable installed protocols
27
+!include_try /usr/share/dovecot/protocols.d/*.protocol
28
+
29
+# A comma separated list of IPs or hosts where to listen in for connections. 
30
+# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.
31
+# If you want to specify non-default ports or anything more complex,
32
+# edit conf.d/master.conf.
33
+#listen = *, ::
34
+
35
+# Base directory where to store runtime data.
36
+#base_dir = /var/run/dovecot/
37
+
38
+# Name of this instance. In multi-instance setup doveadm and other commands
39
+# can use -i <instance_name> to select which instance is used (an alternative
40
+# to -c <config_path>). The instance name is also added to Dovecot processes
41
+# in ps output.
42
+#instance_name = dovecot
43
+
44
+# Greeting message for clients.
45
+#login_greeting = Dovecot ready.
46
+
47
+# Space separated list of trusted network ranges. Connections from these
48
+# IPs are allowed to override their IP addresses and ports (for logging and
49
+# for authentication checks). disable_plaintext_auth is also ignored for
50
+# these networks. Typically you'd specify your IMAP proxy servers here.
51
+#login_trusted_networks =
52
+
53
+# Space separated list of login access check sockets (e.g. tcpwrap)
54
+#login_access_sockets = 
55
+
56
+# With proxy_maybe=yes if proxy destination matches any of these IPs, don't do
57
+# proxying. This isn't necessary normally, but may be useful if the destination
58
+# IP is e.g. a load balancer's IP.
59
+#auth_proxy_self =
60
+
61
+# Show more verbose process titles (in ps). Currently shows user name and
62
+# IP address. Useful for seeing who are actually using the IMAP processes
63
+# (eg. shared mailboxes or if same uid is used for multiple accounts).
64
+#verbose_proctitle = no
65
+
66
+# Should all processes be killed when Dovecot master process shuts down.
67
+# Setting this to "no" means that Dovecot can be upgraded without
68
+# forcing existing client connections to close (although that could also be
69
+# a problem if the upgrade is e.g. because of a security fix).
70
+#shutdown_clients = yes
71
+
72
+# If non-zero, run mail commands via this many connections to doveadm server,
73
+# instead of running them directly in the same process.
74
+#doveadm_worker_count = 0
75
+# UNIX socket or host:port used for connecting to doveadm server
76
+#doveadm_socket_path = doveadm-server
77
+
78
+# Space separated list of environment variables that are preserved on Dovecot
79
+# startup and passed down to all of its child processes. You can also give
80
+# key=value pairs to always set specific settings.
81
+#import_environment = TZ
82
+
83
+##
84
+## Dictionary server settings
85
+##
86
+
87
+# Dictionary can be used to store key=value lists. This is used by several
88
+# plugins. The dictionary can be accessed either directly or though a
89
+# dictionary server. The following dict block maps dictionary names to URIs
90
+# when the server is used. These can then be referenced using URIs in format
91
+# "proxy::<name>".
92
+
93
+dict {
94
+  #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
95
+  #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext
96
+  acl = pgsql:/etc/dovecot/dovecot-dict-sql.conf.ext
97
+}
98
+
99
+# Most of the actual configuration gets included below. The filenames are
100
+# first sorted by their ASCII value and parsed in that order. The 00-prefixes
101
+# in filenames are intended to make it easier to understand the ordering.
102
+!include conf.d/*.conf
103
+
104
+# A config file can also tried to be included without giving an error if
105
+# it's not found:
106
+!include_try local.conf
107
+

+ 5
- 0
mail_system/templates/dovecot/learn-ham.sieve View File

@@ -0,0 +1,5 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+require ["vnd.dovecot.pipe", "copy", "imapsieve"];
5
+pipe :copy "rspamd-learn-ham.sh";

+ 5
- 0
mail_system/templates/dovecot/learn-spam.sieve View File

@@ -0,0 +1,5 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+require ["vnd.dovecot.pipe", "copy", "imapsieve"];
5
+pipe :copy "rspamd-learn-spam.sh";

+ 2
- 0
mail_system/templates/dovecot/rspamd-learn-ham.sh View File

@@ -0,0 +1,2 @@
1
+#!/bin/sh
2
+exec /usr/bin/rspamc learn_ham

+ 2
- 0
mail_system/templates/dovecot/rspamd-learn-spam.sh View File

@@ -0,0 +1,2 @@
1
+#!/bin/sh
2
+exec /usr/bin/rspamc learn_spam

+ 9
- 0
mail_system/templates/dovecot/spam-to-folder.sieve View File

@@ -0,0 +1,9 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+require ["fileinto","mailbox"];
5
+
6
+if header :contains "X-Spam" "Yes" {
7
+    fileinto :create "INBOX.Junk";
8
+    stop;
9
+}

+ 10
- 0
mail_system/templates/postfix/aliases.cf View File

@@ -0,0 +1,10 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# man pgsql_table
5
+
6
+user = {{ mailserver.postgresql.username }}
7
+password = {{ mailserver.postgresql.password }}
8
+dbname = {{ mailserver.postgresql.dbname }}
9
+hosts = {{ mailserver.postgresql.host }}
10
+query = SELECT unnest(forwardings) FROM aliases WHERE alias = '%s'

+ 10
- 0
mail_system/templates/postfix/domains.cf View File

@@ -0,0 +1,10 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# man pgsql_table
5
+
6
+user = {{ mailserver.postgresql.username }}
7
+password = {{ mailserver.postgresql.password }}
8
+dbname = {{ mailserver.postgresql.dbname }}
9
+hosts = {{ mailserver.postgresql.host }}
10
+query = SELECT 1 FROM domains WHERE name='%s' AND relay_transport is null

+ 10
- 0
mail_system/templates/postfix/email_existence_check.cf View File

@@ -0,0 +1,10 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# man pgsql_table
5
+
6
+user = {{ mailserver.postgresql.username }}
7
+password = {{ mailserver.postgresql.password }}
8
+dbname = {{ mailserver.postgresql.dbname }}
9
+hosts = {{ mailserver.postgresql.host }}
10
+query = SELECT users.username || '@' || domains.name FROM users JOIN domains ON users.domain_id=domains.id WHERE domains.relay_transport is null AND users.username='%u' AND users.suspend_submission IS false AND domains.name='%d'

+ 1
- 0
mail_system/templates/postfix/header_checks View File

@@ -0,0 +1 @@
1
+/^Subject:/ WARN

+ 10
- 0
mail_system/templates/postfix/mailboxes.cf View File

@@ -0,0 +1,10 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# man pgsql_table
5
+
6
+user = {{ mailserver.postgresql.username }}
7
+password = {{ mailserver.postgresql.password }}
8
+dbname = {{ mailserver.postgresql.dbname }}
9
+hosts = {{ mailserver.postgresql.host }}
10
+query = SELECT 1 FROM users JOIN domains ON users.domain_id=domains.id WHERE domains.relay_transport is null AND users.username='%u' AND domains.name='%d'

+ 106
- 0
mail_system/templates/postfix/main.cf View File

@@ -0,0 +1,106 @@
1
+# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
2
+
3
+
4
+# See /usr/share/postfix/main.cf.dist for a commented, more complete version
5
+
6
+
7
+# Debian specific:  Specifying a file name will cause the first
8
+# line of that file to be used as the name.  The Debian default