From 89c255825c3b0aee0a5d91a2bc018ea36dda7622 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 19 Dec 2023 16:03:19 +0100 Subject: [PATCH] Implemented email setup for matrix --- roles/docker-baserow/templates/env.j2 | 6 +++--- roles/docker-bigbluebutton/templates/env.j2 | 4 ++-- roles/docker-discourse/templates/app.yml.j2 | 4 ++-- roles/docker-funkwhale/templates/env.j2 | 2 +- .../templates/docker-compose.yml.j2 | 2 +- .../templates/.env.production.j2 | 2 +- .../docker-matrix/templates/homeserver.yaml.j2 | 17 ++++++++++++++++- roles/docker-peertube/templates/env.j2 | 6 +++--- roles/docker-pixelfed/templates/env.j2 | 2 +- .../templates/msmtprc.conf.j2 | 8 ++++++-- 10 files changed, 36 insertions(+), 17 deletions(-) diff --git a/roles/docker-baserow/templates/env.j2 b/roles/docker-baserow/templates/env.j2 index a6ff98fd..db4b80c4 100644 --- a/roles/docker-baserow/templates/env.j2 +++ b/roles/docker-baserow/templates/env.j2 @@ -2,9 +2,9 @@ BASEROW_PUBLIC_URL=https://{{ domain }} # Email Server Configuration -EMAIL_SMTP=True +EMAIL_SMTP={{ system_email_smtp | upper }} EMAIL_SMTP_HOST={{ system_email_host }} -EMAIL_SMTP_PORT={{ system_email_port }} +EMAIL_SMTP_PORT={{ system_email_smtp_port }} EMAIL_SMTP_USER={{ system_email_username }} EMAIL_SMTP_PASSWORD={{ system_email_password }} -EMAIL_SMTP_USE_TLS=tls +EMAIL_SMTP_USE_TLS={{ system_email_tls | upper }} diff --git a/roles/docker-bigbluebutton/templates/env.j2 b/roles/docker-bigbluebutton/templates/env.j2 index 7f70a34b..67fa0182 100644 --- a/roles/docker-bigbluebutton/templates/env.j2 +++ b/roles/docker-bigbluebutton/templates/env.j2 @@ -197,12 +197,12 @@ ALLOW_GREENLIGHT_ACCOUNTS=true SMTP_SERVER={{system_email_host}} SMTP_DOMAIN={{domain}} -SMTP_PORT={{system_email_port}} +SMTP_PORT={{system_email_smtp_port}} SMTP_USERNAME={{system_email_username}} SMTP_PASSWORD={{system_email_password}} SMTP_AUTH=plain SMTP_OPENSSL_VERIFY_MODE=none -SMTP_STARTTLS_AUTO=true +SMTP_STARTTLS_AUTO={{system_email_start_tls}} SMTP_SENDER={{system_email_username}} SMTP_SENDER_EMAIL={{system_email_username}} diff --git a/roles/docker-discourse/templates/app.yml.j2 b/roles/docker-discourse/templates/app.yml.j2 index 68fc6218..659b865d 100644 --- a/roles/docker-discourse/templates/app.yml.j2 +++ b/roles/docker-discourse/templates/app.yml.j2 @@ -64,10 +64,10 @@ env: # SMTP ADDRESS, username, and password are required # WARNING the char '#' in SMTP password can cause problems! DISCOURSE_SMTP_ADDRESS: {{system_email_host}} - DISCOURSE_SMTP_PORT: 587 + DISCOURSE_SMTP_PORT: {{system_email_smtp_port}} DISCOURSE_SMTP_USER_NAME: {{system_email}} DISCOURSE_SMTP_PASSWORD: {{system_email_password}} - DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true) + DISCOURSE_SMTP_ENABLE_START_TLS: {{ system_email_start_tls | upper }} DISCOURSE_SMTP_DOMAIN: {{system_email_domain}} DISCOURSE_NOTIFICATION_EMAIL: {{system_email}} diff --git a/roles/docker-funkwhale/templates/env.j2 b/roles/docker-funkwhale/templates/env.j2 index 69d06127..ec31442b 100644 --- a/roles/docker-funkwhale/templates/env.j2 +++ b/roles/docker-funkwhale/templates/env.j2 @@ -52,7 +52,7 @@ LOGLEVEL=error # (returns `noreply%40youremail.host`) # EMAIL_CONFIG=smtp://user:password@youremail.host:25 # EMAIL_CONFIG=smtp+ssl://user:password@youremail.host:465 -# EMAIL_CONFIG=smtp+tls://user:password@youremail.host:587 +# EMAIL_CONFIG=smtp+tls://user:password@youremail.host:{{system_email_smtp_port}} # Make e-mail verification mandatory before using the service # Doesn't apply to admins. diff --git a/roles/docker-mailu/templates/docker-compose.yml.j2 b/roles/docker-mailu/templates/docker-compose.yml.j2 index 825ed684..fbfd1701 100644 --- a/roles/docker-mailu/templates/docker-compose.yml.j2 +++ b/roles/docker-mailu/templates/docker-compose.yml.j2 @@ -69,7 +69,7 @@ services: - "127.0.0.1:{{ http_port }}:80" - "{{ ip4_address }}:25:25" - "{{ ip4_address }}:465:465" - - "{{ ip4_address }}:{{system_email_port}}:{{system_email_port}}" + - "{{ ip4_address }}:{{system_email_smtp_port}}:{{system_email_smtp_port}}" - "{{ ip4_address }}:110:110" - "{{ ip4_address }}:995:995" - "{{ ip4_address }}:143:143" diff --git a/roles/docker-mastodon/templates/.env.production.j2 b/roles/docker-mastodon/templates/.env.production.j2 index 5aa23c2c..8fce28c6 100644 --- a/roles/docker-mastodon/templates/.env.production.j2 +++ b/roles/docker-mastodon/templates/.env.production.j2 @@ -14,7 +14,7 @@ REDIS_HOST=redis REDIS_PORT=6379 REDIS_PASSWORD= SMTP_SERVER={{system_email_host}} -SMTP_PORT={{system_email_port}} +SMTP_PORT={{system_email_smtp_port}} SMTP_LOGIN={{system_email_username}} SMTP_PASSWORD={{system_email_password}} SMTP_AUTH_METHOD=plain diff --git a/roles/docker-matrix/templates/homeserver.yaml.j2 b/roles/docker-matrix/templates/homeserver.yaml.j2 index ec96d0ee..39ccd99c 100644 --- a/roles/docker-matrix/templates/homeserver.yaml.j2 +++ b/roles/docker-matrix/templates/homeserver.yaml.j2 @@ -28,4 +28,19 @@ web_client_location: "https://{{element_domain}}" public_baseurl: "https://{{synapse_domain}}" trusted_key_servers: - server_name: "matrix.org" -admin_contact: 'mailto:{{administrator_email}}' \ No newline at end of file +admin_contact: 'mailto:{{administrator_email}}' + +email: + smtp_host: "{{system_email_host}}" + smtp_port: "{{system_email_smtp_port}}" + smtp_user: "{{system_email_username}}" + smtp_pass: "{{system_email_password}}" + #force_tls: true + #require_transport_security: true + enable_tls: "{{ system_email_tls | upper }}" + notif_from: "Your Friendly %(app)s homeserver <{{system_email}}>" + app_name: "Matrix on {{top_domain}}" + enable_notifs: true + notif_for_new_users: false + client_base_url: "{{domain_matrix_synapse}}" + validation_token_lifetime: 15m \ No newline at end of file diff --git a/roles/docker-peertube/templates/env.j2 b/roles/docker-peertube/templates/env.j2 index 40e73dce..45dcf130 100644 --- a/roles/docker-peertube/templates/env.j2 +++ b/roles/docker-peertube/templates/env.j2 @@ -17,8 +17,8 @@ PEERTUBE_SECRET={{peertube_secret}} PEERTUBE_SMTP_USERNAME={{system_email_username}} PEERTUBE_SMTP_PASSWORD={{system_email_password}} PEERTUBE_SMTP_HOSTNAME={{system_email_host}} -PEERTUBE_SMTP_PORT={{system_email_port}} +PEERTUBE_SMTP_PORT={{system_email_smtp_port}} PEERTUBE_SMTP_FROM={{system_email}} -PEERTUBE_SMTP_TLS=false -PEERTUBE_SMTP_DISABLE_STARTTLS=false +PEERTUBE_SMTP_TLS={{ system_email_tls | upper }}} +PEERTUBE_SMTP_DISABLE_STARTTLS={{ 'false' if system_email_start_tls else 'true' }} PEERTUBE_ADMIN_EMAIL={{system_email}} \ No newline at end of file diff --git a/roles/docker-pixelfed/templates/env.j2 b/roles/docker-pixelfed/templates/env.j2 index 5af82137..a49dd72d 100644 --- a/roles/docker-pixelfed/templates/env.j2 +++ b/roles/docker-pixelfed/templates/env.j2 @@ -47,7 +47,7 @@ RESTRICTED_INSTANCE=false ## Mail MAIL_DRIVER=log MAIL_HOST={{system_email_host}} -MAIL_PORT={{system_email_port}} +MAIL_PORT={{system_email_smtp_port}} MAIL_FROM_ADDRESS="{{system_email_username}}" MAIL_FROM_NAME="Pixelfed" MAIL_USERNAME={{system_email_username}} diff --git a/roles/systemd-notifier-email/templates/msmtprc.conf.j2 b/roles/systemd-notifier-email/templates/msmtprc.conf.j2 index 44bc0f6d..4f7ed0f2 100644 --- a/roles/systemd-notifier-email/templates/msmtprc.conf.j2 +++ b/roles/systemd-notifier-email/templates/msmtprc.conf.j2 @@ -1,13 +1,17 @@ # Set default values for all following accounts. defaults auth on +logfile ~/.msmtp.log +{% if system_email_tls %} tls on tls_trust_file /etc/ssl/certs/ca-certificates.crt -logfile ~/.msmtp.log +{% else %} +tls off +{% endif %} account system_email host {{system_email_host}} -port {{system_email_port}} +port {{system_email_smtp_port}} from {{system_email}} user {{system_email_username}} password {{system_email_password}}