1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-09-16 09:06:32 +02:00
3864: Allow custom options to be given to fetchmail via environment variable r=mergify[bot] a=DaCHack

## What type of PR?

Feature

## What does this PR do?
PR allows the user to add custom options to fetchmail via environment variable in the docker-compose file

### Related issue(s)
PR can close issue #3863

Pragmatic approach for review by maintainers

Co-authored-by: DaCHack <62812480+DaCHack@users.noreply.github.com>
This commit is contained in:
bors-mailu[bot]
2025-09-07 17:48:30 +00:00
committed by GitHub
5 changed files with 7 additions and 0 deletions

View File

@@ -203,6 +203,7 @@ class FetchForm(flask_wtf.FlaskForm):
password = fields.PasswordField(_('Password'))
keep = fields.BooleanField(_('Keep emails on the server'))
scan = fields.BooleanField(_('Rescan emails locally'))
invisible = fields.BooleanField(_('Keep original metadata (fetchmail invisible)'))
folders = fields.StringField(_('Folders to fetch on the server'), [validators.Optional(), MultipleFoldersVerify()], default='INBOX,Junk')
submit = fields.SubmitField(_('Submit'))

View File

@@ -25,6 +25,7 @@
{%- call macros.card(title="Settings") %}
{{ macros.form_field(form.keep) }}
{{ macros.form_field(form.scan) }}
{{ macros.form_field(form.invisible) }}
{{ macros.form_field(form.folders) }}
{%- endcall %}

View File

@@ -161,6 +161,8 @@ You can add a fetched account by clicking on the `Add an account` button on the
* Scan emails. When ticked, all the fetched emails will go through the local filters (rspamd, clamav, ...).
* Keep original metadata (fetchmail --invisible). When ticked, tries to make Mailu's fetchmail instance invisible. Normally, fetchmail behaves like any other MTA would -- it generates a Received header into each message describing its place in the chain of transmission, and tells the MTA it forwards to that the mail came from the machine fetchmail itself is running on. If the invisible option is on, the Received header is suppressed and fetchmail tries to spoof the MTA it forwards to into thinking it came directly from the mail server host.
* Folders. A comma separated list of folders to fetch from the server. This is optional, by default only the INBOX will be pulled.
Click the submit button to apply settings. With the default polling interval, fetchmail will start polling the email account after ``FETCHMAIL_DELAY``.

View File

@@ -66,8 +66,10 @@ def run(debug):
for fetch in fetches:
fetchmailrc = ""
options = "options antispam 501, 504, 550, 553, 554"
if "FETCHMAIL_OPTIONS" in os.environ: options += f'{ os.environ["FETCHMAIL_OPTIONS"]}'
options += " ssl" if fetch["tls"] else " sslproto \'\'"
options += " keep" if fetch["keep"] else " fetchall"
options += " invisible" if fetch["invisible"] else ""
folders = f"folders {",".join(f'"{imaputf7encode(item).replace('"',r"\34")}"' for item in fetch["folders"]) or '"INBOX"'}"
fetchmailrc += RC_LINE.format(
user_email=escape_rc_string(fetch["user_email"]),

View File

@@ -0,0 +1 @@
Add option for fetchmail's invisible mode as well as further custom options