Add filtermail

This commit is contained in:
link2xt
2023-10-13 21:50:14 +00:00
parent e061d98cfc
commit c9dc32bd10
9 changed files with 201 additions and 13 deletions

View File

@@ -23,10 +23,6 @@ def _install_doveauth() -> None:
src=doveauth_path.open("rb"),
dest=remote_path,
)
apt.packages(
name="apt install python3-pip",
packages="python3-pip",
)
# Maybe if we introduce dependencies to the doveauth package at some point, we should not install doveauth
# system-wide anymore. For now it's fine though.
server.shell(
@@ -35,6 +31,48 @@ def _install_doveauth() -> None:
)
def _install_filtermail() -> None:
"""Setup filtermail."""
filtermail_filename = "filtermail-0.1.tar.gz"
filtermail_path = importlib.resources.files(__package__).joinpath(
f"../../../filtermail/dist/{filtermail_filename}"
)
remote_path = f"/tmp/{filtermail_filename}"
if Path(str(filtermail_path)).exists():
files.put(
name="upload local filtermail build",
src=filtermail_path.open("rb"),
dest=remote_path,
)
apt.packages(
name="apt install python3-aiosmtpd",
packages="python3-aiosmtpd",
)
# --no-deps because aiosmtplib is installed with `apt`.
server.shell(
name="install local doveauth build with pip",
commands=[f"pip install --break-system-packages --no-deps {remote_path}"],
)
files.put(
src=importlib.resources.files(__package__)
.joinpath("../../../filtermail/filtermail.service")
.open("rb"),
dest="/etc/systemd/system/filtermail.service",
user="root",
group="root",
mode="644",
)
systemd.service(
name="Setup filtermail service",
service="filtermail.service",
running=True,
enabled=True,
restarted=True,
)
def _configure_opendkim(domain: str, dkim_selector: str) -> bool:
"""Configures OpenDKIM"""
need_restart = False
@@ -172,7 +210,12 @@ def deploy_chatmail(mail_domain: str, mail_server: str, dkim_selector: str) -> N
],
)
apt.packages(
name="apt install python3-pip",
packages="python3-pip",
)
_install_doveauth()
_install_filtermail()
dovecot_need_restart = _configure_dovecot(mail_server)
postfix_need_restart = _configure_postfix(mail_domain)
opendkim_need_restart = _configure_opendkim(mail_domain, dkim_selector)

View File

@@ -28,6 +28,7 @@ submission inet n - y - - smtpd
-o smtpd_recipient_restrictions=
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
-o content_filter=filter:unix:private/filtemail
smtps inet n - y - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
@@ -42,6 +43,7 @@ smtps inet n - y - - smtpd
-o smtpd_recipient_restrictions=
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
-o content_filter=filter:unix:private/filtermail
#628 inet n - y - - qmqpd
pickup unix n - y 60 1 pickup
cleanup unix n - y - 0 cleanup
@@ -70,3 +72,7 @@ lmtp unix - - y - - lmtp
anvil unix - - y - 1 anvil
scache unix - - y - 1 scache
postlog unix-dgram n - n - 1 postlogd
filter unix - n n - - lmtp
# Local SMTP server for reinjecting filered mail.
localhost:10026 inet n - n - 10 smtpd
-o content_filter=