From 6b9b87a4065b0ebe5e2d5f4ce16120257e723629 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Fri, 25 Jun 2021 11:12:38 -0500 Subject: [PATCH] roles/nextcloud: Configure outbound email Since the Nextcloud configuration file is managed by the configuration policy, all of the settings configurable through the web UI need to be templated. One important group of settings is the outbound email configuration. This can now be configured using the `nextcloud_smtp` Ansible variable. --- group_vars/nextcloud.yml | 4 ++++ roles/nextcloud/templates/config.php.j2 | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/group_vars/nextcloud.yml b/group_vars/nextcloud.yml index 15a6965..7fd24a4 100644 --- a/group_vars/nextcloud.yml +++ b/group_vars/nextcloud.yml @@ -13,3 +13,7 @@ nextcloud_trusted_domains: - nextcloud.pyrocufflink.net - nextcloud.pyrocufflink.blue - '{{ ansible_fqdn }}' +nextcloud_smtp: + from: nextcloud@pyrocufflink.net + host: mail.pyrocufflink.blue + port: 25 diff --git a/roles/nextcloud/templates/config.php.j2 b/roles/nextcloud/templates/config.php.j2 index 1a435ff..3f8a855 100644 --- a/roles/nextcloud/templates/config.php.j2 +++ b/roles/nextcloud/templates/config.php.j2 @@ -49,6 +49,14 @@ $CONFIG = array ( 'maintenance' => {{ nextcloud_maintenance|bool|string|lower }}, 'theme' => '', 'loglevel' => 2, +{% if nextcloud_smtp is defined %} + 'mail_from_address' => '{{ nextcloud_smtp.from.split("@")[0] }}', + 'mail_smtpmode' => 'smtp', + 'mail_sendmailmode' => 'smtp', + 'mail_domain' => '{{ nextcloud_smtp.from.split("@")[1] }}', + 'mail_smtphost' => '{{ nextcloud_smtp.host }}', + 'mail_smtpport' => '{{ nextcloud_smtp.port }}', +{% endif %} 'filelocking.enabled' => true, 'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis',