Add sieve to move spam to junk
This commit is contained in:
parent
a94c5de1b3
commit
aa18f19de9
3 changed files with 43 additions and 0 deletions
7
roles/mailserver_dovecot/handlers/main.yml
Normal file
7
roles/mailserver_dovecot/handlers/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Compile spam-to-folder.sieve
|
||||||
|
become: true
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: sievec /etc/dovecot/sieve-after/spam-to-folder.sieve
|
||||||
|
changed_when: true
|
|
@ -142,3 +142,31 @@
|
||||||
dest: /etc/dovecot/conf.d/90-quota.conf
|
dest: /etc/dovecot/conf.d/90-quota.conf
|
||||||
mode: "644"
|
mode: "644"
|
||||||
notify: Reload dovecot service
|
notify: Reload dovecot service
|
||||||
|
|
||||||
|
- name: Add sieve_after sieve config
|
||||||
|
become: true
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/dovecot/conf.d/90-sieve.conf
|
||||||
|
regexp: '^(\s*)#?sieve_after =.*'
|
||||||
|
backrefs: true
|
||||||
|
line: '\1sieve_after = /etc/dovecot/sieve-after'
|
||||||
|
notify: Reload dovecot service
|
||||||
|
|
||||||
|
- name: Create sieve-after directory
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/dovecot/sieve-after
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "755"
|
||||||
|
|
||||||
|
- name: Copy spam-to-folder.sieve
|
||||||
|
become: true
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: spam-to-folder.sieve.j2
|
||||||
|
dest: /etc/dovecot/sieve-after/spam-to-folder.sieve
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "644"
|
||||||
|
notify: Compile spam-to-folder.sieve
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
require ["fileinto","mailbox"];
|
||||||
|
|
||||||
|
if header :contains "X-Spam" "Yes" {
|
||||||
|
fileinto :create "INBOX.Junk";
|
||||||
|
stop;
|
||||||
|
}
|
Loading…
Reference in a new issue