diff --git a/core/admin/mailu/configuration.py b/core/admin/mailu/configuration.py
index 7ea144d4..d282bfc2 100644
--- a/core/admin/mailu/configuration.py
+++ b/core/admin/mailu/configuration.py
@@ -18,13 +18,14 @@ DEFAULT_CONFIG = {
'DOMAIN_REGISTRATION': False,
'TEMPLATES_AUTO_RELOAD': True,
'MEMORY_SESSIONS': False,
+ 'FETCHMAIL_ENABLED': False,
# Database settings
'DB_FLAVOR': None,
'DB_USER': 'mailu',
'DB_PW': None,
'DB_HOST': 'database',
'DB_NAME': 'mailu',
- 'SQLITE_DATABASE_FILE':'data/main.db',
+ 'SQLITE_DATABASE_FILE': 'data/main.db',
'SQLALCHEMY_DATABASE_URI': 'sqlite:////data/main.db',
'SQLALCHEMY_TRACK_MODIFICATIONS': False,
# Statistics management
@@ -61,7 +62,7 @@ DEFAULT_CONFIG = {
# Web settings
'SITENAME': 'Mailu',
'WEBSITE': 'https://mailu.io',
- 'ADMIN' : 'none',
+ 'ADMIN': 'none',
'WEB_ADMIN': '/admin',
'WEB_WEBMAIL': '/webmail',
'WEBMAIL': 'none',
diff --git a/core/admin/mailu/ui/templates/sidebar.html b/core/admin/mailu/ui/templates/sidebar.html
index a57a2abe..54448c8b 100644
--- a/core/admin/mailu/ui/templates/sidebar.html
+++ b/core/admin/mailu/ui/templates/sidebar.html
@@ -31,12 +31,14 @@
{% trans %}Auto-reply{% endtrans %}
+ {%- if config["FETCHMAIL_ENABLED"] %}
{% trans %}Fetched accounts{% endtrans %}
+ {%- endif %}
diff --git a/core/admin/mailu/ui/views/fetches.py b/core/admin/mailu/ui/views/fetches.py
index ec208af1..ca837a8e 100644
--- a/core/admin/mailu/ui/views/fetches.py
+++ b/core/admin/mailu/ui/views/fetches.py
@@ -1,5 +1,6 @@
from mailu import models
from mailu.ui import ui, forms, access
+from flask import current_app as app
import flask
import flask_login
@@ -10,6 +11,8 @@ import wtforms
@ui.route('/fetch/list/', methods=['GET'])
@access.owner(models.User, 'user_email')
def fetch_list(user_email):
+ if not app.config['FETCHMAIL_ENABLED']:
+ flask.abort(404)
user_email = user_email or flask_login.current_user.email
user = models.User.query.get(user_email) or flask.abort(404)
return flask.render_template('fetch/list.html', user=user)
@@ -19,6 +22,8 @@ def fetch_list(user_email):
@ui.route('/fetch/create/', methods=['GET', 'POST'])
@access.owner(models.User, 'user_email')
def fetch_create(user_email):
+ if not app.config['FETCHMAIL_ENABLED']:
+ flask.abort(404)
user_email = user_email or flask_login.current_user.email
user = models.User.query.get(user_email) or flask.abort(404)
form = forms.FetchForm()
@@ -37,6 +42,8 @@ def fetch_create(user_email):
@ui.route('/fetch/edit/', methods=['GET', 'POST'])
@access.owner(models.Fetch, 'fetch_id')
def fetch_edit(fetch_id):
+ if not app.config['FETCHMAIL_ENABLED']:
+ flask.abort(404)
fetch = models.Fetch.query.get(fetch_id) or flask.abort(404)
form = forms.FetchForm(obj=fetch)
if form.validate_on_submit():
@@ -55,6 +62,8 @@ def fetch_edit(fetch_id):
@access.confirmation_required("delete a fetched account")
@access.owner(models.Fetch, 'fetch_id')
def fetch_delete(fetch_id):
+ if not app.config['FETCHMAIL_ENABLED']:
+ flask.abort(404)
fetch = models.Fetch.query.get(fetch_id) or flask.abort(404)
user = fetch.user
models.db.session.delete(fetch)
diff --git a/core/base/Dockerfile b/core/base/Dockerfile
index 35bcbd15..4639781b 100644
--- a/core/base/Dockerfile
+++ b/core/base/Dockerfile
@@ -8,19 +8,21 @@ ENV TZ=Etc/UTC LANG=C.UTF-8
ARG MAILU_UID=1000
ARG MAILU_GID=1000
+ARG TARGETPLATFORM
RUN set -euxo pipefail \
; addgroup -Sg ${MAILU_GID} mailu \
; adduser -Sg ${MAILU_UID} -G mailu -h /app -g "mailu app" -s /bin/bash mailu \
; apk add --no-cache bash ca-certificates curl python3 tzdata \
; machine="$(uname -m)" \
- ; if [[ "${machine}" == x86_64 || "${machine}" == armv8* || "${machine}" == aarch64 ]] \
- ; then \
- echo "Installing hardened-malloc" \
- ; apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing hardened-malloc \
- ; fi
+ ; [[ "${TARGETPLATFORM}" != linux/arm/v7 && \( "${machine}" == x86_64 || "${machine}" == armv8* || "${machine}" == aarch64 \) ]] \
+ && apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing hardened-malloc
ENV LD_PRELOAD=/usr/lib/libhardened_malloc.so
+ENV CXXFLAGS="-g -O2 -fdebug-prefix-map=/app=. -fstack-protector-strong -Wformat -Werror=format-security -pie -fPIE"
+ENV CFLAGS="-g -O2 -fdebug-prefix-map=/app=. -fstack-protector-strong -Wformat -Werror=format-security -pie -fPIE"
+ENV CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2 -pie -fPIE"
+ENV LDFLAGS="-Wl,-z,relro"
WORKDIR /app
diff --git a/docs/configuration.rst b/docs/configuration.rst
index ba75e0bf..1a40bf65 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -104,6 +104,9 @@ support or e.g. mismatching TLS versions to deliver emails to Mailu.
.. _fetchmail:
+When ``FETCHMAIL_ENABLED`` is set to ``True``, the fetchmail functionality is enabled in the admin interface.
+The container itself still needs to be deployed manually. ``FETCHMAIL_ENABLED`` defaults to ``True``.
+
The ``FETCHMAIL_DELAY`` is a delay (in seconds) for the fetchmail service to
go and fetch new email if available. Do not use too short delays if you do not
want to be blacklisted by external services, but not too long delays if you
diff --git a/optional/fetchmail/fetchmail.py b/optional/fetchmail/fetchmail.py
index 32751ed7..3a82a124 100755
--- a/optional/fetchmail/fetchmail.py
+++ b/optional/fetchmail/fetchmail.py
@@ -95,6 +95,13 @@ def run(debug):
if __name__ == "__main__":
while True:
- time.sleep(int(os.environ.get("FETCHMAIL_DELAY", 60)))
+ delay = int(os.environ.get("FETCHMAIL_DELAY", 60))
+ print("Sleeping for {} seconds".format(delay))
+ time.sleep(delay)
+
+ if not os.environ.get("FETCHMAIL_ENABLED", 'True') in ('True', 'true'):
+ print("Fetchmail disabled, skipping...")
+ continue
+
run(os.environ.get("DEBUG", None) == "True")
sys.stdout.flush()
diff --git a/setup/flavors/compose/mailu.env b/setup/flavors/compose/mailu.env
index df8c4a4d..cc99912e 100644
--- a/setup/flavors/compose/mailu.env
+++ b/setup/flavors/compose/mailu.env
@@ -79,6 +79,9 @@ RELAYNETS=
# Will relay all outgoing mails if configured
RELAYHOST={{ relayhost }}
+# Show fetchmail functionality in admin interface
+FETCHMAIL_ENABLED={{ fetchmail_enabled or 'False' }}
+
# Fetchmail delay
FETCHMAIL_DELAY={{ fetchmail_delay or '600' }}
diff --git a/towncrier/newsfragments/2127.feature b/towncrier/newsfragments/2127.feature
new file mode 100644
index 00000000..dd4951dd
--- /dev/null
+++ b/towncrier/newsfragments/2127.feature
@@ -0,0 +1 @@
+Add FETCHMAIL_ENABLED to toggle the fetchmail functionality in the admin interface
\ No newline at end of file