diff --git a/core/admin/mailu/configuration.py b/core/admin/mailu/configuration.py
index 2f137c0c..e7de2a40 100644
--- a/core/admin/mailu/configuration.py
+++ b/core/admin/mailu/configuration.py
@@ -16,13 +16,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
@@ -59,7 +60,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/docs/configuration.rst b/docs/configuration.rst
index 80f97d3a..58965dff 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -102,6 +102,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 shown in the admin interface.
+The container itself still needs to be deployed manually. As fetchmail is optional, ``FETCHMAIL_ENABLED`` defaults to ``False``.
+
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/setup/flavors/compose/mailu.env b/setup/flavors/compose/mailu.env
index 2963c882..4e13a8c9 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