Move all directories per theme
This commit is contained in:
12
core/dovecot/Dockerfile
Normal file
12
core/dovecot/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM alpine:edge
|
||||
|
||||
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
|
||||
&& apk add --no-cache \
|
||||
dovecot dovecot-sqlite dovecot-pigeonhole-plugin dovecot-pigeonhole-plugin-extdata \
|
||||
rspamd-client@testing python py-jinja2
|
||||
|
||||
COPY conf /conf
|
||||
COPY sieve /var/lib/dovecot
|
||||
COPY start.py /start.py
|
||||
|
||||
CMD /start.py
|
||||
15
core/dovecot/README.md
Normal file
15
core/dovecot/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
Mailu Dovecot container
|
||||
=====================
|
||||
|
||||
Dovecot is an open source IMAP and POP3 email server for Linux/UNIX-like
|
||||
systems, written with security primarily in mind. It's fast, simple to set
|
||||
up, requires no special administration and it uses very little memory.
|
||||
|
||||
In the Mailu stack it is used as the IMAP/POP frontend service.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Report issues](https://github.com/Mailu/Mailu/issues) and
|
||||
[send Pull Requests](https://github.com/Mailu/Mailu/pulls)
|
||||
in the [main Mailu repository](https://github.com/Mailu/Mailu)
|
||||
14
core/dovecot/conf/dovecot-sql.conf.ext
Normal file
14
core/dovecot/conf/dovecot-sql.conf.ext
Normal file
@@ -0,0 +1,14 @@
|
||||
driver = sqlite
|
||||
connect = /data/main.db
|
||||
|
||||
# Return the user hashed password
|
||||
password_query = \
|
||||
SELECT NULL as password, 'Y' as nopassword, '{{ FRONT_ADDRESS }}' as allow_nets \
|
||||
FROM user \
|
||||
WHERE user.email = '%u'
|
||||
|
||||
# Mostly get the user quota
|
||||
user_query = \
|
||||
SELECT '*:bytes=' || user.quota_bytes AS quota_rule \
|
||||
FROM user \
|
||||
WHERE user.email = '%u'
|
||||
178
core/dovecot/conf/dovecot.conf
Normal file
178
core/dovecot/conf/dovecot.conf
Normal file
@@ -0,0 +1,178 @@
|
||||
###############
|
||||
# General
|
||||
###############
|
||||
log_path = /dev/stderr
|
||||
protocols = imap pop3 lmtp sieve
|
||||
postmaster_address = {{ POSTMASTER }}@{{ DOMAIN }}
|
||||
hostname = {{ HOSTNAMES.split(",")[0] }}
|
||||
mail_plugins = $mail_plugins quota
|
||||
submission_host = front
|
||||
|
||||
service dict {
|
||||
unix_listener dict {
|
||||
group = mail
|
||||
mode = 0660
|
||||
}
|
||||
}
|
||||
|
||||
dict {
|
||||
sieve = sqlite:/etc/dovecot/pigeonhole-sieve.dict
|
||||
}
|
||||
|
||||
###############
|
||||
# Mailboxes
|
||||
###############
|
||||
first_valid_gid = 8
|
||||
first_valid_uid = 8
|
||||
mail_location = maildir:/mail/%u
|
||||
mail_home = /mail/%u
|
||||
mail_uid = mail
|
||||
mail_gid = mail
|
||||
mail_privileged_group = mail
|
||||
mail_access_groups = mail
|
||||
maildir_stat_dirs = yes
|
||||
|
||||
namespace inbox {
|
||||
inbox = yes
|
||||
mailbox Trash {
|
||||
auto = subscribe
|
||||
special_use = \Trash
|
||||
}
|
||||
mailbox Drafts {
|
||||
auto = subscribe
|
||||
special_use = \Drafts
|
||||
}
|
||||
mailbox Sent {
|
||||
auto = subscribe
|
||||
special_use = \Sent
|
||||
}
|
||||
mailbox Junk {
|
||||
auto = subscribe
|
||||
special_use = \Junk
|
||||
}
|
||||
}
|
||||
|
||||
###############
|
||||
# Authentication
|
||||
###############
|
||||
auth_mechanisms = plain login
|
||||
disable_plaintext_auth = no
|
||||
|
||||
passdb {
|
||||
driver = sql
|
||||
args = /etc/dovecot/dovecot-sql.conf.ext
|
||||
}
|
||||
|
||||
userdb {
|
||||
driver = sql
|
||||
args = /etc/dovecot/dovecot-sql.conf.ext
|
||||
}
|
||||
|
||||
service auth {
|
||||
user = dovecot
|
||||
unix_listener auth-userdb {
|
||||
}
|
||||
}
|
||||
|
||||
service auth-worker {
|
||||
unix_listener auth-worker {
|
||||
user = dovecot
|
||||
group = mail
|
||||
mode = 0660
|
||||
}
|
||||
user = mail
|
||||
}
|
||||
|
||||
###############
|
||||
# IMAP & POP
|
||||
###############
|
||||
|
||||
protocol imap {
|
||||
mail_plugins = $mail_plugins imap_quota imap_sieve
|
||||
}
|
||||
|
||||
protocol pop3 {
|
||||
|
||||
}
|
||||
|
||||
service imap-login {
|
||||
inet_listener imap {
|
||||
port = 143
|
||||
}
|
||||
}
|
||||
|
||||
###############
|
||||
# Delivery
|
||||
###############
|
||||
|
||||
protocol lmtp {
|
||||
mail_plugins = $mail_plugins sieve
|
||||
recipient_delimiter = {{ RECIPIENT_DELIMITER }}
|
||||
}
|
||||
|
||||
service lmtp {
|
||||
inet_listener lmtp {
|
||||
port = 2525
|
||||
}
|
||||
}
|
||||
|
||||
plugin {
|
||||
quota = maildir:User quota
|
||||
}
|
||||
|
||||
|
||||
###############
|
||||
# Filtering
|
||||
###############
|
||||
|
||||
service managesieve-login {
|
||||
inet_listener sieve {
|
||||
port = 4190
|
||||
}
|
||||
}
|
||||
|
||||
service managesieve {
|
||||
}
|
||||
|
||||
plugin {
|
||||
sieve = file:~/sieve;active=~/.dovecot.sieve
|
||||
sieve_plugins = sieve_extdata sieve_imapsieve sieve_extprograms
|
||||
sieve_global_extensions = +vnd.dovecot.extdata +spamtest +spamtestplus +vnd.dovecot.execute
|
||||
sieve_before = /var/lib/dovecot/before.sieve
|
||||
sieve_default = /var/lib/dovecot/default.sieve
|
||||
sieve_after = /var/lib/dovecot/after.sieve
|
||||
sieve_extdata_dict_uri = proxy::sieve
|
||||
|
||||
# Sieve execute
|
||||
sieve_execute_bin_dir = /var/lib/dovecot/bin
|
||||
|
||||
# Send vacation replies even for aliases
|
||||
# See the Pigeonhole documentation about warnings: http://wiki2.dovecot.org/Pigeonhole/Sieve/Extensions/Vacation
|
||||
# It appears that our implemntation of mail delivery meets criteria of section 4.5
|
||||
# from RFC 5230 and that disabling the recipient checks is not an issue here.
|
||||
sieve_vacation_dont_check_recipient = yes
|
||||
|
||||
# Include the recipient in vacation replies so that DKIM applies
|
||||
sieve_vacation_send_from_recipient = yes
|
||||
|
||||
# extract spam score from
|
||||
# X-Spam-Result: .... [<value> / <max_value] ...
|
||||
sieve_spamtest_status_type = score
|
||||
sieve_spamtest_status_header = X-Spamd-Result: .*\[(-?[[:digit:]]+\.[[:digit:]]+) .*\]
|
||||
sieve_spamtest_max_header = X-Spamd-Result: .*\[.* ([[:digit:]]+\.[[:digit:]]+)\]
|
||||
|
||||
# Learn from spam
|
||||
imapsieve_mailbox1_name = Junk
|
||||
imapsieve_mailbox1_causes = COPY
|
||||
imapsieve_mailbox1_before = file:/var/lib/dovecot/report-spam.sieve
|
||||
imapsieve_mailbox2_name = *
|
||||
imapsieve_mailbox2_from = Junk
|
||||
imapsieve_mailbox2_causes = COPY
|
||||
imapsieve_mailbox2_before = file:/var/lib/dovecot/report-ham.sieve
|
||||
}
|
||||
|
||||
###############
|
||||
# Extensions
|
||||
###############
|
||||
|
||||
!include_try /overrides/dovecot.conf
|
||||
36
core/dovecot/conf/pigeonhole-sieve.dict
Normal file
36
core/dovecot/conf/pigeonhole-sieve.dict
Normal file
@@ -0,0 +1,36 @@
|
||||
connect = /data/main.db
|
||||
|
||||
map {
|
||||
pattern = priv/spam_enabled
|
||||
table = user
|
||||
username_field = email
|
||||
value_field = spam_enabled
|
||||
}
|
||||
|
||||
map {
|
||||
pattern = priv/spam_threshold
|
||||
table = user
|
||||
username_field = email
|
||||
value_field = spam_threshold
|
||||
}
|
||||
|
||||
map {
|
||||
pattern = priv/reply_enabled
|
||||
table = user
|
||||
username_field = email
|
||||
value_field = reply_enabled
|
||||
}
|
||||
|
||||
map {
|
||||
pattern = priv/reply_subject
|
||||
table = user
|
||||
username_field = email
|
||||
value_field = reply_subject
|
||||
}
|
||||
|
||||
map {
|
||||
pattern = priv/reply_body
|
||||
table = user
|
||||
username_field = email
|
||||
value_field = reply_body
|
||||
}
|
||||
0
core/dovecot/sieve/after.sieve
Normal file
0
core/dovecot/sieve/after.sieve
Normal file
24
core/dovecot/sieve/before.sieve
Normal file
24
core/dovecot/sieve/before.sieve
Normal file
@@ -0,0 +1,24 @@
|
||||
require "variables";
|
||||
require "vacation";
|
||||
require "fileinto";
|
||||
require "envelope";
|
||||
require "mailbox";
|
||||
require "imap4flags";
|
||||
require "regex";
|
||||
require "relational";
|
||||
require "comparator-i;ascii-numeric";
|
||||
require "vnd.dovecot.extdata";
|
||||
require "vnd.dovecot.execute";
|
||||
require "spamtestplus";
|
||||
|
||||
if allof (string :is "${extdata.spam_enabled}" "1",
|
||||
spamtest :percent :value "gt" :comparator "i;ascii-numeric" "${extdata.spam_threshold}")
|
||||
{
|
||||
setflag "\\seen";
|
||||
fileinto :create "Junk";
|
||||
stop;
|
||||
}
|
||||
|
||||
if string :is "${extdata.reply_enabled}" "1" {
|
||||
vacation :days 1 :subject "${extdata.reply_subject}" "${extdata.reply_body}";
|
||||
}
|
||||
3
core/dovecot/sieve/bin/mailtrain
Executable file
3
core/dovecot/sieve/bin/mailtrain
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
rspamc -h antispam:11334 -P mailu "learn_$1" /dev/stdin <&0
|
||||
0
core/dovecot/sieve/default.sieve
Normal file
0
core/dovecot/sieve/default.sieve
Normal file
3
core/dovecot/sieve/report-ham.sieve
Normal file
3
core/dovecot/sieve/report-ham.sieve
Normal file
@@ -0,0 +1,3 @@
|
||||
require "vnd.dovecot.execute";
|
||||
|
||||
execute :pipe "mailtrain" "ham";
|
||||
3
core/dovecot/sieve/report-spam.sieve
Normal file
3
core/dovecot/sieve/report-spam.sieve
Normal file
@@ -0,0 +1,3 @@
|
||||
require "vnd.dovecot.execute";
|
||||
|
||||
execute :pipe "mailtrain" "spam";
|
||||
18
core/dovecot/start.py
Executable file
18
core/dovecot/start.py
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import jinja2
|
||||
import os
|
||||
import socket
|
||||
import glob
|
||||
|
||||
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
|
||||
|
||||
# Actual startup script
|
||||
os.environ["FRONT_ADDRESS"] = socket.gethostbyname("front")
|
||||
|
||||
for dovecot_file in glob.glob("/conf/*"):
|
||||
convert(dovecot_file, os.path.join("/etc/dovecot", os.path.basename(dovecot_file)))
|
||||
|
||||
# Run postfix
|
||||
os.system("chown -R mail:mail /mail /var/lib/dovecot")
|
||||
os.execv("/usr/sbin/dovecot", ["dovecot", "-c", "/etc/dovecot/dovecot.conf", "-F"])
|
||||
Reference in New Issue
Block a user