Commit a2583331 authored by Hinrikus Wolf's avatar Hinrikus Wolf
Browse files

change dovecot s.t. a spamfilter can be plugged in

parent 66ef3d39
require "fileinto";
if header :contains "X-Spam-Flag" "YES" {
fileinto "Junk";
}
if header :contains "Subject" "*SPAM*" {
fileinto "Junk";
}
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}
if string "${mailbox}" "Trash" {
stop;
}
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "sa-learn-ham.sh" [ "${username}" ];
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "sa-learn-spam.sh" [ "${username}" ];
......@@ -3,3 +3,8 @@
- name: restart dovecot
service: name=dovecot state=restarted
- name: compile sieve script
shell: "sievec /var/lib/dovecot/sieve.d/*.sieve"
......@@ -31,6 +31,25 @@
- dovecot
- mail
- name: ensure there is a folder for global sieve scripts
file: dest=/var/lib/dovecot/sieve.d state=directory owner=dovecot group=vmail mode=0770
tags:
- dovecot
- mail
when: content_filter is defined
- name: ensure the global spam filter and learning sieve script is present
copy: src="files/{{ item }}" dest="/var/lib/dovecot/sieve.d/{{ item }}" mode=0550 owner=dovecot group=vmail
with_items:
- filter_junk.sieve
- report-spam.sieve
- report-ham.sieve
notify:
- compile sieve script
tags:
- dovecot
- mail
when: content_filter is defined
- name: ensure dsync config is present
template: src=templates/conf.d/99-dsync.conf.j2 dest=/etc/dovecot/conf.d/99-dsync.conf
......
......@@ -75,3 +75,25 @@ protocol imap {
#mail_max_userip_connections = 10
mail_max_userip_connections = 40
}
{% if content_filter is defined %}
plugin {
sieve_plugins = sieve_imapsieve sieve_extprograms
# From elsewhere to Spam folder
imapsieve_mailbox1_name = Junk
imapsieve_mailbox1_causes = COPY
imapsieve_mailbox1_before = file:/usr/lib/dovecot/sieve.d/report-spam.sieve
# From Spam folder to elsewhere
imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Junk
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve.d/report-ham.sieve
sieve_pipe_bin_dir = /usr/lib/dovecot/sieve.d
sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
}
{% endif %}
......@@ -76,6 +76,9 @@ plugin {
#sieve_before = /var/lib/dovecot/sieve.d/
#sieve_before2 = ldap:/etc/sieve-ldap.conf;name=ldap-domain
#sieve_before3 = (etc...)
{% if content_filter is defined %}
sieve_before = /var/lib/dovecot/sieve.d/filter_junk.sieve
{% endif %}
# Identical to sieve_before, only the specified scripts are executed after the
# user's script (only when keep is still in effect!). Multiple script
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment