Merge branch 'master' into feat-reply-startdate
commit
c6846fd8db
@ -0,0 +1,10 @@
|
|||||||
|
rules:
|
||||||
|
default: null
|
||||||
|
branches:
|
||||||
|
master:
|
||||||
|
protection:
|
||||||
|
required_status_checks:
|
||||||
|
contexts:
|
||||||
|
- continuous-integration/travis-ci
|
||||||
|
required_pull_request_reviews:
|
||||||
|
required_approving_review_count: 2
|
@ -0,0 +1,3 @@
|
|||||||
|
__all__ = [
|
||||||
|
'auth', 'postfix', 'dovecot', 'fetch'
|
||||||
|
]
|
@ -0,0 +1,40 @@
|
|||||||
|
from mailu import db, models
|
||||||
|
from mailu.internal import internal
|
||||||
|
|
||||||
|
import flask
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/dovecot/passdb/<user_email>")
|
||||||
|
def dovecot_passdb_dict(user_email):
|
||||||
|
user = models.User.query.get(user_email) or flask.abort(404)
|
||||||
|
return flask.jsonify({
|
||||||
|
"password": user.password,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/dovecot/userdb/<user_email>")
|
||||||
|
def dovecot_userdb_dict(user_email):
|
||||||
|
user = models.User.query.get(user_email) or flask.abort(404)
|
||||||
|
return flask.jsonify({
|
||||||
|
"quota_rule": "*:bytes={}".format(user.quota_bytes)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/dovecot/quota/<ns>/<user_email>", methods=["POST"])
|
||||||
|
def dovecot_quota(ns, user_email):
|
||||||
|
user = models.User.query.get(user_email) or flask.abort(404)
|
||||||
|
if ns == "storage":
|
||||||
|
user.quota_bytes_used = flask.request.get_json()
|
||||||
|
db.session.commit()
|
||||||
|
return flask.jsonify(None)
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/dovecot/sieve/name/<script>/<user_email>")
|
||||||
|
def dovecot_sieve_name(script, user_email):
|
||||||
|
return flask.jsonify(script)
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/dovecot/sieve/data/default/<user_email>")
|
||||||
|
def dovecot_sieve_data(user_email):
|
||||||
|
user = models.User.query.get(user_email) or flask.abort(404)
|
||||||
|
return flask.jsonify(flask.render_template("default.sieve", user=user))
|
@ -0,0 +1,32 @@
|
|||||||
|
from mailu import db, models
|
||||||
|
from mailu.internal import internal
|
||||||
|
|
||||||
|
import flask
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/fetch")
|
||||||
|
def fetch_list():
|
||||||
|
return flask.jsonify([
|
||||||
|
{
|
||||||
|
"id": fetch.id,
|
||||||
|
"tls": fetch.tls,
|
||||||
|
"keep": fetch.keep,
|
||||||
|
"user_email": fetch.user_email,
|
||||||
|
"protocol": fetch.protocol,
|
||||||
|
"host": fetch.host,
|
||||||
|
"port": fetch.port,
|
||||||
|
"username": fetch.username,
|
||||||
|
"password": fetch.password
|
||||||
|
} for fetch in models.Fetch.query.all()
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/fetch/<fetch_id>", methods=["POST"])
|
||||||
|
def fetch_done(fetch_id):
|
||||||
|
fetch = models.Fetch.query.get(fetch_id) or flask.abort(404)
|
||||||
|
fetch.last_check = datetime.datetime.now()
|
||||||
|
fetch.error_message = str(flask.request.get_json())
|
||||||
|
db.session.add(fetch)
|
||||||
|
db.session.commit()
|
||||||
|
return ""
|
@ -0,0 +1,54 @@
|
|||||||
|
from mailu import db, models
|
||||||
|
from mailu.internal import internal
|
||||||
|
|
||||||
|
import flask
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/postfix/domain/<domain_name>")
|
||||||
|
def postfix_mailbox_domain(domain_name):
|
||||||
|
domain = models.Domain.query.get(domain_name) or flask.abort(404)
|
||||||
|
return flask.jsonify(domain.name)
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/postfix/mailbox/<email>")
|
||||||
|
def postfix_mailbox_map(email):
|
||||||
|
user = models.User.query.get(email) or flask.abort(404)
|
||||||
|
return flask.jsonify(user.email)
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/postfix/alias/<alias>")
|
||||||
|
def postfix_alias_map(alias):
|
||||||
|
localpart, domain = alias.split('@', 1) if '@' in alias else (None, alias)
|
||||||
|
alternative = models.Alternative.query.get(domain)
|
||||||
|
if alternative:
|
||||||
|
domain = alternative.domain_name
|
||||||
|
email = '{}@{}'.format(localpart, domain)
|
||||||
|
if localpart is None:
|
||||||
|
return flask.jsonify(domain)
|
||||||
|
else:
|
||||||
|
alias_obj = models.Alias.resolve(localpart, domain)
|
||||||
|
if alias_obj:
|
||||||
|
return flask.jsonify(",".join(alias_obj.destination))
|
||||||
|
user_obj = models.User.query.get(email)
|
||||||
|
if user_obj:
|
||||||
|
return flask.jsonify(user_obj.destination)
|
||||||
|
return flask.abort(404)
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/postfix/transport/<email>")
|
||||||
|
def postfix_transport(email):
|
||||||
|
localpart, domain = email.split('@', 1) if '@' in email else (None, email)
|
||||||
|
relay = models.Relay.query.get(domain) or flask.abort(404)
|
||||||
|
return flask.jsonify("smtp:[{}]".format(relay.smtp))
|
||||||
|
|
||||||
|
|
||||||
|
@internal.route("/postfix/sender/<sender>")
|
||||||
|
def postfix_sender(sender):
|
||||||
|
""" Simply reject any sender that pretends to be from a local domain
|
||||||
|
"""
|
||||||
|
localpart, domain_name = sender.split('@', 1) if '@' in sender else (None, sender)
|
||||||
|
domain = models.Domain.query.get(domain_name)
|
||||||
|
alternative = models.Alternative.query.get(domain_name)
|
||||||
|
if domain or alternative:
|
||||||
|
return flask.jsonify("REJECT")
|
||||||
|
return flask.abort(404)
|
@ -0,0 +1,28 @@
|
|||||||
|
""" Add a column for used quota
|
||||||
|
|
||||||
|
Revision ID: 25fd6c7bcb4a
|
||||||
|
Revises: 049fed905da7
|
||||||
|
Create Date: 2018-07-25 21:56:09.729153
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '25fd6c7bcb4a'
|
||||||
|
down_revision = '049fed905da7'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
with op.batch_alter_table('user') as batch:
|
||||||
|
batch.add_column(sa.Column('quota_bytes_used', sa.Integer(), nullable=False, server_default='0'))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
with op.batch_alter_table('user') as batch:
|
||||||
|
batch.drop_column('user', 'quota_bytes_used')
|
@ -1,14 +1,15 @@
|
|||||||
FROM alpine:3.7
|
FROM alpine:3.8
|
||||||
|
|
||||||
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
|
RUN apk add --no-cache \
|
||||||
&& apk add --no-cache \
|
dovecot dovecot-pigeonhole-plugin dovecot-fts-lucene rspamd-client \
|
||||||
dovecot dovecot-sqlite dovecot-pigeonhole-plugin dovecot-pigeonhole-plugin-extdata \
|
python3 py3-pip \
|
||||||
dovecot-fts-lucene rspamd-client@testing python py-jinja2
|
&& pip3 install --upgrade pip \
|
||||||
|
&& pip3 install jinja2 podop tenacity
|
||||||
|
|
||||||
COPY conf /conf
|
COPY conf /conf
|
||||||
COPY sieve /var/lib/dovecot
|
|
||||||
COPY start.py /start.py
|
COPY start.py /start.py
|
||||||
|
|
||||||
EXPOSE 110/tcp 143/tcp 993/tcp 4190/tcp 2525/tcp
|
EXPOSE 110/tcp 143/tcp 993/tcp 4190/tcp 2525/tcp
|
||||||
|
VOLUME ["/data", "/mail"]
|
||||||
|
|
||||||
CMD /start.py
|
CMD /start.py
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
uri = proxy:/tmp/podop.socket:auth
|
||||||
|
iterate_disable = yes
|
||||||
|
default_pass_scheme = plain
|
||||||
|
password_key = passdb/%u
|
||||||
|
user_key = userdb/%u
|
@ -1,18 +0,0 @@
|
|||||||
driver = sqlite
|
|
||||||
connect = /data/main.db
|
|
||||||
|
|
||||||
# Return the user hashed password
|
|
||||||
password_query = \
|
|
||||||
SELECT NULL as password, 'Y' as nopassword, '{% if POD_ADDRESS_RANGE %}{{ POD_ADDRESS_RANGE }}{% else %}{{ FRONT_ADDRESS }}{% if WEBMAIL_ADDRESS %},{{ WEBMAIL_ADDRESS }}{% endif %}{% endif %}' 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'
|
|
||||||
|
|
||||||
# For using doveadm -A:
|
|
||||||
iterate_query = \
|
|
||||||
SELECT user.email AS user FROM user
|
|
@ -1,51 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
map {
|
|
||||||
pattern = priv/reply_enddate
|
|
||||||
table = user
|
|
||||||
username_field = email
|
|
||||||
value_field = reply_enddate
|
|
||||||
}
|
|
||||||
|
|
||||||
map {
|
|
||||||
pattern = priv/reply_startdate
|
|
||||||
table = user
|
|
||||||
username_field = email
|
|
||||||
value_field = reply_startdate
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +1,40 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import glob
|
import glob
|
||||||
|
import multiprocessing
|
||||||
|
import tenacity
|
||||||
|
|
||||||
|
from tenacity import retry
|
||||||
|
from podop import run_server
|
||||||
|
|
||||||
|
|
||||||
|
def start_podop():
|
||||||
|
os.setuid(8)
|
||||||
|
run_server(3 if "DEBUG" in os.environ else 0, "dovecot", "/tmp/podop.socket", [
|
||||||
|
("quota", "url", "http://admin/internal/dovecot/§"),
|
||||||
|
("auth", "url", "http://admin/internal/dovecot/§"),
|
||||||
|
("sieve", "url", "http://admin/internal/dovecot/§"),
|
||||||
|
])
|
||||||
|
|
||||||
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
|
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
|
||||||
|
|
||||||
# Actual startup script
|
@retry(stop=tenacity.stop_after_attempt(100), wait=tenacity.wait_random(min=2, max=5))
|
||||||
|
def resolve():
|
||||||
os.environ["FRONT_ADDRESS"] = socket.gethostbyname(os.environ.get("FRONT_ADDRESS", "front"))
|
os.environ["FRONT_ADDRESS"] = socket.gethostbyname(os.environ.get("FRONT_ADDRESS", "front"))
|
||||||
os.environ["REDIS_ADDRESS"] = socket.gethostbyname(os.environ.get("REDIS_ADDRESS", "redis"))
|
os.environ["REDIS_ADDRESS"] = socket.gethostbyname(os.environ.get("REDIS_ADDRESS", "redis"))
|
||||||
if os.environ["WEBMAIL"] != "none":
|
if os.environ["WEBMAIL"] != "none":
|
||||||
os.environ["WEBMAIL_ADDRESS"] = socket.gethostbyname(os.environ.get("WEBMAIL_ADDRESS", "webmail"))
|
os.environ["WEBMAIL_ADDRESS"] = socket.gethostbyname(os.environ.get("WEBMAIL_ADDRESS", "webmail"))
|
||||||
|
|
||||||
for dovecot_file in glob.glob("/conf/*"):
|
# Actual startup script
|
||||||
|
resolve()
|
||||||
|
|
||||||
|
for dovecot_file in glob.glob("/conf/*.conf"):
|
||||||
convert(dovecot_file, os.path.join("/etc/dovecot", os.path.basename(dovecot_file)))
|
convert(dovecot_file, os.path.join("/etc/dovecot", os.path.basename(dovecot_file)))
|
||||||
|
|
||||||
# Run postfix
|
# Run Podop, then postfix
|
||||||
|
multiprocessing.Process(target=start_podop).start()
|
||||||
os.system("chown -R mail:mail /mail /var/lib/dovecot")
|
os.system("chown -R mail:mail /mail /var/lib/dovecot")
|
||||||
os.execv("/usr/sbin/dovecot", ["dovecot", "-c", "/etc/dovecot/dovecot.conf", "-F"])
|
os.execv("/usr/sbin/dovecot", ["dovecot", "-c", "/etc/dovecot/dovecot.conf", "-F"])
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
FROM alpine:3.7
|
FROM alpine:3.8
|
||||||
|
|
||||||
RUN apk add --no-cache nginx nginx-mod-mail python py-jinja2 certbot openssl
|
RUN apk add --no-cache certbot nginx nginx-mod-mail openssl \
|
||||||
|
python py-jinja2 py-requests-toolbelt py-pip \
|
||||||
|
&& pip install --upgrade pip \
|
||||||
|
&& pip install idna
|
||||||
|
|
||||||
COPY conf /conf
|
COPY conf /conf
|
||||||
COPY *.py /
|
COPY *.py /
|
||||||
|
|
||||||
EXPOSE 80/tcp 443/tcp 110/tcp 143/tcp 465/tcp 587/tcp 993/tcp 995/tcp 25/tcp 10025/tcp 10143/tcp
|
EXPOSE 80/tcp 443/tcp 110/tcp 143/tcp 465/tcp 587/tcp 993/tcp 995/tcp 25/tcp 10025/tcp 10143/tcp
|
||||||
|
VOLUME ["/certs"]
|
||||||
|
|
||||||
CMD /start.py
|
CMD /start.py
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# This is an idle image to dynamically replace any component if disabled.
|
# This is an idle image to dynamically replace any component if disabled.
|
||||||
|
|
||||||
FROM alpine
|
FROM alpine:3.8
|
||||||
|
|
||||||
CMD sleep 1000000d
|
CMD sleep 1000000d
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
FROM alpine:3.7
|
FROM alpine:3.8
|
||||||
|
|
||||||
RUN apk add --no-cache postfix postfix-sqlite postfix-pcre rsyslog python py-jinja2
|
RUN apk add --no-cache postfix postfix-pcre rsyslog \
|
||||||
|
python3 py3-pip \
|
||||||
|
&& pip3 install --upgrade pip \
|
||||||
|
&& pip3 install jinja2 podop tenacity
|
||||||
|
|
||||||
COPY conf /conf
|
COPY conf /conf
|
||||||
COPY start.py /start.py
|
COPY start.py /start.py
|
||||||
|
|
||||||
EXPOSE 25/tcp 10025/tcp
|
EXPOSE 25/tcp 10025/tcp
|
||||||
|
VOLUME ["/data"]
|
||||||
|
|
||||||
CMD /start.py
|
CMD /start.py
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
dbpath = /data/main.db
|
|
||||||
query =
|
|
||||||
SELECT 'REJECT' FROM domain WHERE name='%s'
|
|
||||||
UNION
|
|
||||||
SELECT 'REJECT' FROM alternative WHERE name='%s'
|
|
@ -1,3 +0,0 @@
|
|||||||
dbpath = /data/main.db
|
|
||||||
query =
|
|
||||||
SELECT 'smtp:['||smtp||']' FROM relay WHERE name='%s'
|
|
@ -1,23 +0,0 @@
|
|||||||
dbpath = /data/main.db
|
|
||||||
query =
|
|
||||||
SELECT destination
|
|
||||||
FROM
|
|
||||||
(SELECT destination, email, wildcard, localpart, localpart||'@'||alternative.name AS alt_email FROM alias LEFT JOIN alternative ON alias.domain_name = alternative.domain_name
|
|
||||||
UNION
|
|
||||||
SELECT (CASE WHEN forward_enabled=1 THEN (CASE WHEN forward_keep=1 THEN email||',' ELSE '' END)||forward_destination ELSE email END) AS destination, email, 0 as wildcard, localpart, localpart||'@'||alternative.name as alt_email FROM user LEFT JOIN alternative ON user.domain_name = alternative.domain_name
|
|
||||||
UNION
|
|
||||||
SELECT '@'||domain_name as destination, '@'||name as email, 0 as wildcard, '' as localpart, NULL AS alt_email FROM alternative)
|
|
||||||
WHERE
|
|
||||||
(
|
|
||||||
wildcard = 0
|
|
||||||
AND
|
|
||||||
(email = '%s' OR alt_email = '%s')
|
|
||||||
) OR (
|
|
||||||
wildcard = 1
|
|
||||||
AND
|
|
||||||
'%s' LIKE email
|
|
||||||
)
|
|
||||||
ORDER BY
|
|
||||||
wildcard ASC,
|
|
||||||
length(localpart) DESC
|
|
||||||
LIMIT 1
|
|
@ -1,5 +0,0 @@
|
|||||||
dbpath = /data/main.db
|
|
||||||
query =
|
|
||||||
SELECT name FROM domain WHERE name='%s'
|
|
||||||
UNION
|
|
||||||
SELECT name FROM alternative WHERE name='%s'
|
|
@ -0,0 +1,14 @@
|
|||||||
|
FROM python:3-alpine
|
||||||
|
|
||||||
|
COPY requirements.txt /requirements.txt
|
||||||
|
|
||||||
|
RUN pip install -r /requirements.txt \
|
||||||
|
&& apk add --no-cache nginx \
|
||||||
|
&& mkdir /run/nginx
|
||||||
|
|
||||||
|
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY . /docs
|
||||||
|
|
||||||
|
RUN sphinx-build /docs /build
|
||||||
|
|
||||||
|
CMD nginx -g "daemon off;"
|
@ -0,0 +1,5 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
root /build;
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
FROM python:alpine
|
FROM python:3-alpine
|
||||||
|
|
||||||
RUN apk add --no-cache fetchmail ca-certificates
|
RUN apk add --no-cache fetchmail ca-certificates \
|
||||||
|
&& pip install requests
|
||||||
|
|
||||||
COPY fetchmail.py /fetchmail.py
|
COPY fetchmail.py /fetchmail.py
|
||||||
|
USER fetchmail
|
||||||
|
|
||||||
CMD ["/fetchmail.py"]
|
CMD ["/fetchmail.py"]
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
try_fallback = true;
|
||||||
|
path = "/dkim/$domain.$selector.key";
|
||||||
|
selector = "dkim"
|
||||||
|
use_esld = false;
|
@ -0,0 +1,134 @@
|
|||||||
|
# Mailu main configuration file
|
||||||
|
#
|
||||||
|
# Most configuration variables can be modified through the Web interface,
|
||||||
|
# these few settings must however be configured before starting the mail
|
||||||
|
# server and require a restart upon change.
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# Common configuration variables
|
||||||
|
###################################
|
||||||
|
|
||||||
|
# Set this to the path where Mailu data and configuration is stored
|
||||||
|
ROOT=/mailu
|
||||||
|
|
||||||
|
# Mailu version to run (1.0, 1.1, etc. or master)
|
||||||
|
#VERSION=master
|
||||||
|
|
||||||
|
# Set to a randomly generated 16 bytes string
|
||||||
|
SECRET_KEY=ChangeMeChangeMe
|
||||||
|
|
||||||
|
# Address where listening ports should bind
|
||||||
|
BIND_ADDRESS4=127.0.0.1
|
||||||
|
#BIND_ADDRESS6=::1
|
||||||
|
|
||||||
|
# Main mail domain
|
||||||
|
DOMAIN=mailu.io
|
||||||
|
|
||||||
|
# Hostnames for this server, separated with comas
|
||||||
|
HOSTNAMES=mail.mailu.io,alternative.mailu.io,yetanother.mailu.io
|
||||||
|
|
||||||
|
# Postmaster local part (will append the main mail domain)
|
||||||
|
POSTMASTER=admin
|
||||||
|
|
||||||
|
# Choose how secure connections will behave (value: letsencrypt, cert, notls, mail, mail-letsencrypt)
|
||||||
|
TLS_FLAVOR=cert
|
||||||
|
|
||||||
|
# Authentication rate limit (per source IP address)
|
||||||
|
AUTH_RATELIMIT=10/minute;1000/hour
|
||||||
|
|
||||||
|
# Opt-out of statistics, replace with "True" to opt out
|
||||||
|
DISABLE_STATISTICS=False
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# Optional features
|
||||||
|
###################################
|
||||||
|
|
||||||
|
# Expose the admin interface (value: true, false)
|
||||||
|
ADMIN=false
|
||||||
|
|
||||||
|
# Choose which webmail to run if any (values: roundcube, rainloop, none)
|
||||||
|
WEBMAIL=none
|
||||||
|
|
||||||
|
# Dav server implementation (value: radicale, none)
|
||||||
|
WEBDAV=none
|
||||||
|
|
||||||
|
# Antivirus solution (value: clamav, none)
|
||||||
|
ANTIVIRUS=none
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# Mail settings
|
||||||
|
###################################
|
||||||
|
|
||||||
|
# Message size limit in bytes
|
||||||
|
# Default: accept messages up to 50MB
|
||||||
|
MESSAGE_SIZE_LIMIT=50000000
|
||||||
|
|
||||||
|
# Networks granted relay permissions, make sure that you include your Docker
|
||||||
|
# internal network (default to 172.17.0.0/16)
|
||||||
|
RELAYNETS=172.16.0.0/12
|
||||||
|
|
||||||
|
# Will relay all outgoing mails if configured
|
||||||
|
RELAYHOST=
|
||||||
|
|
||||||
|
# Fetchmail delay
|
||||||
|
FETCHMAIL_DELAY=600
|
||||||
|
|
||||||
|
# Recipient delimiter, character used to delimiter localpart from custom address part
|
||||||
|
# e.g. localpart+custom@domain;tld
|
||||||
|
RECIPIENT_DELIMITER=+
|
||||||
|
|
||||||
|
# DMARC rua and ruf email
|
||||||
|
DMARC_RUA=admin
|
||||||
|
DMARC_RUF=admin
|
||||||
|
|
||||||
|
# Welcome email, enable and set a topic and body if you wish to send welcome
|
||||||
|
# emails to all users.
|
||||||
|
WELCOME=false
|
||||||
|
WELCOME_SUBJECT=Welcome to your new email account
|
||||||
|
WELCOME_BODY=Welcome to your new email account, if you can read this, then it is configured properly!
|
||||||
|
|
||||||
|
# Maildir Compression
|
||||||
|
# choose compression-method, default: none (value: bz2, gz)
|
||||||
|
COMPRESSION=
|
||||||
|
# change compression-level, default: 6 (value: 1-9)
|
||||||
|
COMPRESSION_LEVEL=
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# Web settings
|
||||||
|
###################################
|
||||||
|
|
||||||
|
# Path to the admin interface if enabled
|
||||||
|
WEB_ADMIN=/admin
|
||||||
|
|
||||||
|
# Path to the webmail if enabled
|
||||||
|
WEB_WEBMAIL=/webmail
|
||||||
|
|
||||||
|
# Website name
|
||||||
|
SITENAME=Mailu
|
||||||
|
|
||||||
|
# Linked Website URL
|
||||||
|
WEBSITE=https://mailu.io
|
||||||
|
|
||||||
|
# Registration reCaptcha settings (warning, this has some privacy impact)
|
||||||
|
# RECAPTCHA_PUBLIC_KEY=
|
||||||
|
# RECAPTCHA_PRIVATE_KEY=
|
||||||
|
|
||||||
|
# Domain registration, uncomment to enable
|
||||||
|
# DOMAIN_REGISTRATION=true
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# Advanced settings
|
||||||
|
###################################
|
||||||
|
|
||||||
|
# Docker-compose project name, this will prepended to containers names.
|
||||||
|
#COMPOSE_PROJECT_NAME=mailu
|
||||||
|
|
||||||
|
# Default password scheme used for newly created accounts and changed passwords
|
||||||
|
# (value: SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT)
|
||||||
|
PASSWORD_SCHEME=SHA512-CRYPT
|
||||||
|
|
||||||
|
# Header to take the real ip from
|
||||||
|
REAL_IP_HEADER=
|
||||||
|
|
||||||
|
# IPs for nginx set_real_ip_from (CIDR list separated by commas)
|
||||||
|
REAL_IP_FROM=
|
@ -0,0 +1,99 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
front:
|
||||||
|
image: $DOCKER_ORG/nginx:$VERSION
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
ports:
|
||||||
|
- "$BIND_ADDRESS4:80:80"
|
||||||
|
- "$BIND_ADDRESS4:443:443"
|
||||||
|
- "$BIND_ADDRESS4:110:110"
|
||||||
|
- "$BIND_ADDRESS4:143:143"
|
||||||
|
- "$BIND_ADDRESS4:993:993"
|
||||||
|
- "$BIND_ADDRESS4:995:995"
|
||||||
|
- "$BIND_ADDRESS4:25:25"
|
||||||
|
- "$BIND_ADDRESS4:465:465"
|
||||||
|
- "$BIND_ADDRESS4:587:587"
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/certs:/certs"
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:alpine
|
||||||
|
restart: 'no'
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/redis:/data"
|
||||||
|
|
||||||
|
imap:
|
||||||
|
image: $DOCKER_ORG/dovecot:$VERSION
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/data:/data"
|
||||||
|
- "$ROOT/mail:/mail"
|
||||||
|
- "$ROOT/overrides:/overrides"
|
||||||
|
depends_on:
|
||||||
|
- front
|
||||||
|
|
||||||
|
smtp:
|
||||||
|
image: $DOCKER_ORG/postfix:$VERSION
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/data:/data"
|
||||||
|
- "$ROOT/overrides:/overrides"
|
||||||
|
depends_on:
|
||||||
|
- front
|
||||||
|
|
||||||
|
antispam:
|
||||||
|
image: $DOCKER_ORG/rspamd:$VERSION
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/filter:/var/lib/rspamd"
|
||||||
|
- "$ROOT/dkim:/dkim"
|
||||||
|
- "$ROOT/overrides/rspamd:/etc/rspamd/override.d"
|
||||||
|
depends_on:
|
||||||
|
- front
|
||||||
|
|
||||||
|
antivirus:
|
||||||
|
image: $DOCKER_ORG/$ANTIVIRUS:$VERSION
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/filter:/data"
|
||||||
|
|
||||||
|
webdav:
|
||||||
|
image: $DOCKER_ORG/$WEBDAV:$VERSION
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/dav:/data"
|
||||||
|
|
||||||
|
admin:
|
||||||
|
image: $DOCKER_ORG/admin:$VERSION
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/data:/data"
|
||||||
|
- "$ROOT/dkim:/dkim"
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
|
||||||
|
webmail:
|
||||||
|
image: "$DOCKER_ORG/$WEBMAIL:$VERSION"
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/webmail:/data"
|
||||||
|
depends_on:
|
||||||
|
- imap
|
||||||
|
|
||||||
|
fetchmail:
|
||||||
|
image: $DOCKER_ORG/fetchmail:$VERSION
|
||||||
|
restart: 'no'
|
||||||
|
env_file: $PWD/.env
|
||||||
|
volumes:
|
||||||
|
- "$ROOT/data:/data"
|
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
containers=(
|
||||||
|
webmail
|
||||||
|
imap
|
||||||
|
smtp
|
||||||
|
antispam
|
||||||
|
admin
|
||||||
|
redis
|
||||||
|
antivirus
|
||||||
|
webdav
|
||||||
|
# fetchmail
|
||||||
|
front
|
||||||
|
)
|
||||||
|
|
||||||
|
# Time to sleep in minutes after starting the containers
|
||||||
|
WAIT=1
|
||||||
|
|
||||||
|
containers_check() {
|
||||||
|
status=0
|
||||||
|
for container in "${containers[@]}"; do
|
||||||
|
name="${DOCKER_ORG}_${container}_1"
|
||||||
|
echo "Checking $name"
|
||||||
|
docker inspect "$name" | grep '"Status": "running"' || status=1
|
||||||
|
done
|
||||||
|
docker ps -a
|
||||||
|
return $status
|
||||||
|
}
|
||||||
|
|
||||||
|
container_logs() {
|
||||||
|
for container in "${containers[@]}"; do
|
||||||
|
name="${DOCKER_ORG}_${container}_1"
|
||||||
|
echo "Showing logs for $name"
|
||||||
|
docker container logs "$name"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
clean() {
|
||||||
|
docker-compose -f tests/compose/run.yml -p $DOCKER_ORG down || exit 1
|
||||||
|
rm -fv .env
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cleanup before callig exit
|
||||||
|
die() {
|
||||||
|
clean
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
for file in tests/compose/*.env ; do
|
||||||
|
cp $file .env
|
||||||
|
docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d
|
||||||
|
echo -e "\nSleeping for ${WAIT} minutes" # Clean terminal distortion from docker-compose in travis
|
||||||
|
travis_wait sleep ${WAIT}m || sleep ${WAIT}m #Fallback sleep for local run
|
||||||
|
container_logs
|
||||||
|
containers_check || die 1
|
||||||
|
clean
|
||||||
|
done
|
||||||
|
|
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker login -u $DOCKER_UN -p $DOCKER_PW
|
||||||
|
docker-compose -f tests/build.yml push
|
@ -0,0 +1,17 @@
|
|||||||
|
import smtplib
|
||||||
|
import sys
|
||||||
|
from email import mime
|
||||||
|
|
||||||
|
from email.mime.image import MIMEImage
|
||||||
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
|
||||||
|
msg = mime.multipart.MIMEMultipart()
|
||||||
|
msg['Subject'] = 'Test email'
|
||||||
|
msg['From'] = sys.argv[1]
|
||||||
|
msg['To'] = sys.argv[2]
|
||||||
|
msg.preamble = 'Test email'
|
||||||
|
|
||||||
|
s = smtplib.SMTP('localhost')
|
||||||
|
s.set_debuglevel(1)
|
||||||
|
s.send_message(msg)
|
||||||
|
s.quit()
|
Loading…
Reference in New Issue