Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Projects
Groups
Snippets
Sign up now
Login
Sign in
Toggle navigation
Menu
Open sidebar
infra
ansible-shared
communication
Commits
a2583331
Commit
a2583331
authored
May 16, 2018
by
Hinrikus Wolf
Browse files
change dovecot s.t. a spamfilter can be plugged in
parent
66ef3d39
Changes
7
Hide whitespace changes
Inline
Side-by-side
dovecot/files/filter_junk.sieve
0 → 100644
View file @
a2583331
require
"fileinto"
;
if
header
:contains
"X-Spam-Flag"
"YES"
{
fileinto
"Junk"
;
}
if
header
:contains
"Subject"
"*SPAM*"
{
fileinto
"Junk"
;
}
dovecot/files/report-ham.sieve
0 → 100644
View file @
a2583331
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}
"
];
dovecot/files/report-spam.sieve
0 → 100644
View file @
a2583331
require
[
"vnd.dovecot.pipe"
,
"copy"
,
"imapsieve"
,
"environment"
,
"variables"
];
if
environment
:matches
"imap.user"
"*"
{
set
"username"
"
${1}
"
;
}
pipe
:copy
"sa-learn-spam.sh"
[
"
${username}
"
];
dovecot/handlers/main.yml
View file @
a2583331
...
...
@@ -3,3 +3,8 @@
-
name
:
restart dovecot
service
:
name=dovecot state=restarted
-
name
:
compile sieve script
shell
:
"
sievec
/var/lib/dovecot/sieve.d/*.sieve"
dovecot/tasks/main.yml
View file @
a2583331
...
...
@@ -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
...
...
dovecot/templates/conf.d/20-imap.conf.j2
View file @
a2583331
...
...
@@ -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 %}
dovecot/templates/conf.d/90-sieve.conf.j2
View file @
a2583331
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment