We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Timezone in containers
Hello,

I have seen that timezones are not set for containers. This causes logs to have wrong timestamps and email "received" headers have wrong timezones.

It should be possible to set the timezone for all containers. The setting should be exposed and described in the .env file.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `core/admin/mailu/configuration.py`
Content:
```
1 import os
2 
3 from datetime import timedelta
4 from socrate import system
5 import ipaddress
6 
7 DEFAULT_CONFIG = {
8     # Specific to the admin UI
9     'DOCKER_SOCKET': 'unix:///var/run/docker.sock',
10     'BABEL_DEFAULT_LOCALE': 'en',
11     'BABEL_DEFAULT_TIMEZONE': 'UTC',
12     'BOOTSTRAP_SERVE_LOCAL': True,
13     'RATELIMIT_STORAGE_URL': '',
14     'QUOTA_STORAGE_URL': '',
15     'DEBUG': False,
16     'DOMAIN_REGISTRATION': False,
17     'TEMPLATES_AUTO_RELOAD': True,
18     'MEMORY_SESSIONS': False,
19     # Database settings
20     'DB_FLAVOR': None,
21     'DB_USER': 'mailu',
22     'DB_PW': None,
23     'DB_HOST': 'database',
24     'DB_NAME': 'mailu',
25     'SQLITE_DATABASE_FILE':'data/main.db',
26     'SQLALCHEMY_DATABASE_URI': 'sqlite:////data/main.db',
27     'SQLALCHEMY_TRACK_MODIFICATIONS': False,
28     # Statistics management
29     'INSTANCE_ID_PATH': '/data/instance',
30     'STATS_ENDPOINT': '18.{}.stats.mailu.io',
31     # Common configuration variables
32     'SECRET_KEY': 'changeMe',
33     'DOMAIN': 'mailu.io',
34     'HOSTNAMES': 'mail.mailu.io,alternative.mailu.io,yetanother.mailu.io',
35     'POSTMASTER': 'postmaster',
36     'WILDCARD_SENDERS': '',
37     'TLS_FLAVOR': 'cert',
38     'INBOUND_TLS_ENFORCE': False,
39     'DEFER_ON_TLS_ERROR': True,
40     'AUTH_RATELIMIT_IP': '60/hour',
41     'AUTH_RATELIMIT_IP_V4_MASK': 24,
42     'AUTH_RATELIMIT_IP_V6_MASK': 56,
43     'AUTH_RATELIMIT_USER': '100/day',
44     'AUTH_RATELIMIT_EXEMPTION': '',
45     'AUTH_RATELIMIT_EXEMPTION_LENGTH': 86400,
46     'DISABLE_STATISTICS': False,
47     # Mail settings
48     'DMARC_RUA': None,
49     'DMARC_RUF': None,
50     'WELCOME': False,
51     'WELCOME_SUBJECT': 'Dummy welcome topic',
52     'WELCOME_BODY': 'Dummy welcome body',
53     'DKIM_SELECTOR': 'dkim',
54     'DKIM_PATH': '/dkim/{domain}.{selector}.key',
55     'DEFAULT_QUOTA': 1000000000,
56     'MESSAGE_RATELIMIT': '200/day',
57     'RECIPIENT_DELIMITER': '',
58     # Web settings
59     'SITENAME': 'Mailu',
60     'WEBSITE': 'https://mailu.io',
61     'ADMIN' : 'none',
62     'WEB_ADMIN': '/admin',
63     'WEB_WEBMAIL': '/webmail',
64     'WEBMAIL': 'none',
65     'RECAPTCHA_PUBLIC_KEY': '',
66     'RECAPTCHA_PRIVATE_KEY': '',
67     'LOGO_URL': None,
68     'LOGO_BACKGROUND': None,
69     # Advanced settings
70     'LOG_LEVEL': 'WARNING',
71     'SESSION_KEY_BITS': 128,
72     'SESSION_LIFETIME': 24,
73     'SESSION_COOKIE_SECURE': True,
74     'CREDENTIAL_ROUNDS': 12,
75     # Host settings
76     'HOST_IMAP': 'imap',
77     'HOST_LMTP': 'imap:2525',
78     'HOST_POP3': 'imap',
79     'HOST_SMTP': 'smtp',
80     'HOST_AUTHSMTP': 'smtp',
81     'HOST_ADMIN': 'admin',
82     'HOST_WEBMAIL': 'webmail',
83     'HOST_WEBDAV': 'webdav:5232',
84     'HOST_REDIS': 'redis',
85     'HOST_FRONT': 'front',
86     'SUBNET': '192.168.203.0/24',
87     'SUBNET6': None,
88     'POD_ADDRESS_RANGE': None
89 }
90 
91 class ConfigManager(dict):
92     """ Naive configuration manager that uses environment only
93     """
94 
95     DB_TEMPLATES = {
96         'sqlite': 'sqlite:////{SQLITE_DATABASE_FILE}',
97         'postgresql': 'postgresql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}',
98         'mysql': 'mysql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}'
99     }
100 
101     def __init__(self):
102         self.config = dict()
103 
104     def get_host_address(self, name):
105         # if MYSERVICE_ADDRESS is defined, use this
106         if '{}_ADDRESS'.format(name) in os.environ:
107             return os.environ.get('{}_ADDRESS'.format(name))
108         # otherwise use the host name and resolve it
109         return system.resolve_address(self.config['HOST_{}'.format(name)])
110 
111     def resolve_hosts(self):
112         self.config["IMAP_ADDRESS"] = self.get_host_address("IMAP")
113         self.config["POP3_ADDRESS"] = self.get_host_address("POP3")
114         self.config["AUTHSMTP_ADDRESS"] = self.get_host_address("AUTHSMTP")
115         self.config["SMTP_ADDRESS"] = self.get_host_address("SMTP")
116         self.config["REDIS_ADDRESS"] = self.get_host_address("REDIS")
117         if self.config["WEBMAIL"] != "none":
118             self.config["WEBMAIL_ADDRESS"] = self.get_host_address("WEBMAIL")
119 
120     def __get_env(self, key, value):
121         key_file = key + "_FILE"
122         if key_file in os.environ:
123             with open(os.environ.get(key_file)) as file:
124                 value_from_file = file.read()
125             return value_from_file.strip()
126         else:
127             return os.environ.get(key, value)
128 
129     def __coerce_value(self, value):
130         if isinstance(value, str) and value.lower() in ('true','yes'):
131             return True
132         elif isinstance(value, str) and value.lower() in ('false', 'no'):
133             return False
134         return value
135 
136     def init_app(self, app):
137         self.config.update(app.config)
138         # get environment variables
139         self.config.update({
140             key: self.__coerce_value(self.__get_env(key, value))
141             for key, value in DEFAULT_CONFIG.items()
142         })
143         self.resolve_hosts()
144 
145         # automatically set the sqlalchemy string
146         if self.config['DB_FLAVOR']:
147             template = self.DB_TEMPLATES[self.config['DB_FLAVOR']]
148             self.config['SQLALCHEMY_DATABASE_URI'] = template.format(**self.config)
149 
150         self.config['RATELIMIT_STORAGE_URL'] = 'redis://{0}/2'.format(self.config['REDIS_ADDRESS'])
151         self.config['QUOTA_STORAGE_URL'] = 'redis://{0}/1'.format(self.config['REDIS_ADDRESS'])
152         self.config['SESSION_STORAGE_URL'] = 'redis://{0}/3'.format(self.config['REDIS_ADDRESS'])
153         self.config['SESSION_COOKIE_SAMESITE'] = 'Strict'
154         self.config['SESSION_COOKIE_HTTPONLY'] = True
155         self.config['PERMANENT_SESSION_LIFETIME'] = timedelta(hours=int(self.config['SESSION_LIFETIME']))
156         hostnames = [host.strip() for host in self.config['HOSTNAMES'].split(',')]
157         self.config['AUTH_RATELIMIT_EXEMPTION'] = set(ipaddress.ip_network(cidr, False) for cidr in (cidr.strip() for cidr in self.config['AUTH_RATELIMIT_EXEMPTION'].split(',')) if cidr)
158         self.config['HOSTNAMES'] = ','.join(hostnames)
159         self.config['HOSTNAME'] = hostnames[0]
160         # update the app config itself
161         app.config = self
162 
163     def setdefault(self, key, value):
164         if key not in self.config:
165             self.config[key] = value
166         return self.config[key]
167 
168     def get(self, *args):
169         return self.config.get(*args)
170 
171     def keys(self):
172         return self.config.keys()
173 
174     def __getitem__(self, key):
175         return self.config.get(key)
176 
177     def __setitem__(self, key, value):
178         self.config[key] = value
179 
180     def __contains__(self, key):
181         return key in self.config
182
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/core/admin/mailu/configuration.py b/core/admin/mailu/configuration.py
--- a/core/admin/mailu/configuration.py
+++ b/core/admin/mailu/configuration.py
@@ -72,6 +72,7 @@
     'SESSION_LIFETIME': 24,
     'SESSION_COOKIE_SECURE': True,
     'CREDENTIAL_ROUNDS': 12,
+    'TZ': 'Etc/UTC',
     # Host settings
     'HOST_IMAP': 'imap',
     'HOST_LMTP': 'imap:2525',

{"golden_diff": "diff --git a/core/admin/mailu/configuration.py b/core/admin/mailu/configuration.py\n--- a/core/admin/mailu/configuration.py\n+++ b/core/admin/mailu/configuration.py\n@@ -72,6 +72,7 @@\n     'SESSION_LIFETIME': 24,\n     'SESSION_COOKIE_SECURE': True,\n     'CREDENTIAL_ROUNDS': 12,\n+    'TZ': 'Etc/UTC',\n     # Host settings\n     'HOST_IMAP': 'imap',\n     'HOST_LMTP': 'imap:2525',\n", "issue": "Timezone in containers\nHello,\r\n\r\nI have seen that timezones are not set for containers. This causes logs to have wrong timestamps and email \"received\" headers have wrong timezones.\r\n\r\nIt should be possible to set the timezone for all containers. The setting should be exposed and described in the .env file.\n", "before_files": [{"content": "import os\n\nfrom datetime import timedelta\nfrom socrate import system\nimport ipaddress\n\nDEFAULT_CONFIG = {\n    # Specific to the admin UI\n    'DOCKER_SOCKET': 'unix:///var/run/docker.sock',\n    'BABEL_DEFAULT_LOCALE': 'en',\n    'BABEL_DEFAULT_TIMEZONE': 'UTC',\n    'BOOTSTRAP_SERVE_LOCAL': True,\n    'RATELIMIT_STORAGE_URL': '',\n    'QUOTA_STORAGE_URL': '',\n    'DEBUG': False,\n    'DOMAIN_REGISTRATION': False,\n    'TEMPLATES_AUTO_RELOAD': True,\n    'MEMORY_SESSIONS': False,\n    # Database settings\n    'DB_FLAVOR': None,\n    'DB_USER': 'mailu',\n    'DB_PW': None,\n    'DB_HOST': 'database',\n    'DB_NAME': 'mailu',\n    'SQLITE_DATABASE_FILE':'data/main.db',\n    'SQLALCHEMY_DATABASE_URI': 'sqlite:////data/main.db',\n    'SQLALCHEMY_TRACK_MODIFICATIONS': False,\n    # Statistics management\n    'INSTANCE_ID_PATH': '/data/instance',\n    'STATS_ENDPOINT': '18.{}.stats.mailu.io',\n    # Common configuration variables\n    'SECRET_KEY': 'changeMe',\n    'DOMAIN': 'mailu.io',\n    'HOSTNAMES': 'mail.mailu.io,alternative.mailu.io,yetanother.mailu.io',\n    'POSTMASTER': 'postmaster',\n    'WILDCARD_SENDERS': '',\n    'TLS_FLAVOR': 'cert',\n    'INBOUND_TLS_ENFORCE': False,\n    'DEFER_ON_TLS_ERROR': True,\n    'AUTH_RATELIMIT_IP': '60/hour',\n    'AUTH_RATELIMIT_IP_V4_MASK': 24,\n    'AUTH_RATELIMIT_IP_V6_MASK': 56,\n    'AUTH_RATELIMIT_USER': '100/day',\n    'AUTH_RATELIMIT_EXEMPTION': '',\n    'AUTH_RATELIMIT_EXEMPTION_LENGTH': 86400,\n    'DISABLE_STATISTICS': False,\n    # Mail settings\n    'DMARC_RUA': None,\n    'DMARC_RUF': None,\n    'WELCOME': False,\n    'WELCOME_SUBJECT': 'Dummy welcome topic',\n    'WELCOME_BODY': 'Dummy welcome body',\n    'DKIM_SELECTOR': 'dkim',\n    'DKIM_PATH': '/dkim/{domain}.{selector}.key',\n    'DEFAULT_QUOTA': 1000000000,\n    'MESSAGE_RATELIMIT': '200/day',\n    'RECIPIENT_DELIMITER': '',\n    # Web settings\n    'SITENAME': 'Mailu',\n    'WEBSITE': 'https://mailu.io',\n    'ADMIN' : 'none',\n    'WEB_ADMIN': '/admin',\n    'WEB_WEBMAIL': '/webmail',\n    'WEBMAIL': 'none',\n    'RECAPTCHA_PUBLIC_KEY': '',\n    'RECAPTCHA_PRIVATE_KEY': '',\n    'LOGO_URL': None,\n    'LOGO_BACKGROUND': None,\n    # Advanced settings\n    'LOG_LEVEL': 'WARNING',\n    'SESSION_KEY_BITS': 128,\n    'SESSION_LIFETIME': 24,\n    'SESSION_COOKIE_SECURE': True,\n    'CREDENTIAL_ROUNDS': 12,\n    # Host settings\n    'HOST_IMAP': 'imap',\n    'HOST_LMTP': 'imap:2525',\n    'HOST_POP3': 'imap',\n    'HOST_SMTP': 'smtp',\n    'HOST_AUTHSMTP': 'smtp',\n    'HOST_ADMIN': 'admin',\n    'HOST_WEBMAIL': 'webmail',\n    'HOST_WEBDAV': 'webdav:5232',\n    'HOST_REDIS': 'redis',\n    'HOST_FRONT': 'front',\n    'SUBNET': '192.168.203.0/24',\n    'SUBNET6': None,\n    'POD_ADDRESS_RANGE': None\n}\n\nclass ConfigManager(dict):\n    \"\"\" Naive configuration manager that uses environment only\n    \"\"\"\n\n    DB_TEMPLATES = {\n        'sqlite': 'sqlite:////{SQLITE_DATABASE_FILE}',\n        'postgresql': 'postgresql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}',\n        'mysql': 'mysql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}'\n    }\n\n    def __init__(self):\n        self.config = dict()\n\n    def get_host_address(self, name):\n        # if MYSERVICE_ADDRESS is defined, use this\n        if '{}_ADDRESS'.format(name) in os.environ:\n            return os.environ.get('{}_ADDRESS'.format(name))\n        # otherwise use the host name and resolve it\n        return system.resolve_address(self.config['HOST_{}'.format(name)])\n\n    def resolve_hosts(self):\n        self.config[\"IMAP_ADDRESS\"] = self.get_host_address(\"IMAP\")\n        self.config[\"POP3_ADDRESS\"] = self.get_host_address(\"POP3\")\n        self.config[\"AUTHSMTP_ADDRESS\"] = self.get_host_address(\"AUTHSMTP\")\n        self.config[\"SMTP_ADDRESS\"] = self.get_host_address(\"SMTP\")\n        self.config[\"REDIS_ADDRESS\"] = self.get_host_address(\"REDIS\")\n        if self.config[\"WEBMAIL\"] != \"none\":\n            self.config[\"WEBMAIL_ADDRESS\"] = self.get_host_address(\"WEBMAIL\")\n\n    def __get_env(self, key, value):\n        key_file = key + \"_FILE\"\n        if key_file in os.environ:\n            with open(os.environ.get(key_file)) as file:\n                value_from_file = file.read()\n            return value_from_file.strip()\n        else:\n            return os.environ.get(key, value)\n\n    def __coerce_value(self, value):\n        if isinstance(value, str) and value.lower() in ('true','yes'):\n            return True\n        elif isinstance(value, str) and value.lower() in ('false', 'no'):\n            return False\n        return value\n\n    def init_app(self, app):\n        self.config.update(app.config)\n        # get environment variables\n        self.config.update({\n            key: self.__coerce_value(self.__get_env(key, value))\n            for key, value in DEFAULT_CONFIG.items()\n        })\n        self.resolve_hosts()\n\n        # automatically set the sqlalchemy string\n        if self.config['DB_FLAVOR']:\n            template = self.DB_TEMPLATES[self.config['DB_FLAVOR']]\n            self.config['SQLALCHEMY_DATABASE_URI'] = template.format(**self.config)\n\n        self.config['RATELIMIT_STORAGE_URL'] = 'redis://{0}/2'.format(self.config['REDIS_ADDRESS'])\n        self.config['QUOTA_STORAGE_URL'] = 'redis://{0}/1'.format(self.config['REDIS_ADDRESS'])\n        self.config['SESSION_STORAGE_URL'] = 'redis://{0}/3'.format(self.config['REDIS_ADDRESS'])\n        self.config['SESSION_COOKIE_SAMESITE'] = 'Strict'\n        self.config['SESSION_COOKIE_HTTPONLY'] = True\n        self.config['PERMANENT_SESSION_LIFETIME'] = timedelta(hours=int(self.config['SESSION_LIFETIME']))\n        hostnames = [host.strip() for host in self.config['HOSTNAMES'].split(',')]\n        self.config['AUTH_RATELIMIT_EXEMPTION'] = set(ipaddress.ip_network(cidr, False) for cidr in (cidr.strip() for cidr in self.config['AUTH_RATELIMIT_EXEMPTION'].split(',')) if cidr)\n        self.config['HOSTNAMES'] = ','.join(hostnames)\n        self.config['HOSTNAME'] = hostnames[0]\n        # update the app config itself\n        app.config = self\n\n    def setdefault(self, key, value):\n        if key not in self.config:\n            self.config[key] = value\n        return self.config[key]\n\n    def get(self, *args):\n        return self.config.get(*args)\n\n    def keys(self):\n        return self.config.keys()\n\n    def __getitem__(self, key):\n        return self.config.get(key)\n\n    def __setitem__(self, key, value):\n        self.config[key] = value\n\n    def __contains__(self, key):\n        return key in self.config\n", "path": "core/admin/mailu/configuration.py"}], "after_files": [{"content": "import os\n\nfrom datetime import timedelta\nfrom socrate import system\nimport ipaddress\n\nDEFAULT_CONFIG = {\n    # Specific to the admin UI\n    'DOCKER_SOCKET': 'unix:///var/run/docker.sock',\n    'BABEL_DEFAULT_LOCALE': 'en',\n    'BABEL_DEFAULT_TIMEZONE': 'UTC',\n    'BOOTSTRAP_SERVE_LOCAL': True,\n    'RATELIMIT_STORAGE_URL': '',\n    'QUOTA_STORAGE_URL': '',\n    'DEBUG': False,\n    'DOMAIN_REGISTRATION': False,\n    'TEMPLATES_AUTO_RELOAD': True,\n    'MEMORY_SESSIONS': False,\n    # Database settings\n    'DB_FLAVOR': None,\n    'DB_USER': 'mailu',\n    'DB_PW': None,\n    'DB_HOST': 'database',\n    'DB_NAME': 'mailu',\n    'SQLITE_DATABASE_FILE':'data/main.db',\n    'SQLALCHEMY_DATABASE_URI': 'sqlite:////data/main.db',\n    'SQLALCHEMY_TRACK_MODIFICATIONS': False,\n    # Statistics management\n    'INSTANCE_ID_PATH': '/data/instance',\n    'STATS_ENDPOINT': '18.{}.stats.mailu.io',\n    # Common configuration variables\n    'SECRET_KEY': 'changeMe',\n    'DOMAIN': 'mailu.io',\n    'HOSTNAMES': 'mail.mailu.io,alternative.mailu.io,yetanother.mailu.io',\n    'POSTMASTER': 'postmaster',\n    'WILDCARD_SENDERS': '',\n    'TLS_FLAVOR': 'cert',\n    'INBOUND_TLS_ENFORCE': False,\n    'DEFER_ON_TLS_ERROR': True,\n    'AUTH_RATELIMIT_IP': '60/hour',\n    'AUTH_RATELIMIT_IP_V4_MASK': 24,\n    'AUTH_RATELIMIT_IP_V6_MASK': 56,\n    'AUTH_RATELIMIT_USER': '100/day',\n    'AUTH_RATELIMIT_EXEMPTION': '',\n    'AUTH_RATELIMIT_EXEMPTION_LENGTH': 86400,\n    'DISABLE_STATISTICS': False,\n    # Mail settings\n    'DMARC_RUA': None,\n    'DMARC_RUF': None,\n    'WELCOME': False,\n    'WELCOME_SUBJECT': 'Dummy welcome topic',\n    'WELCOME_BODY': 'Dummy welcome body',\n    'DKIM_SELECTOR': 'dkim',\n    'DKIM_PATH': '/dkim/{domain}.{selector}.key',\n    'DEFAULT_QUOTA': 1000000000,\n    'MESSAGE_RATELIMIT': '200/day',\n    'RECIPIENT_DELIMITER': '',\n    # Web settings\n    'SITENAME': 'Mailu',\n    'WEBSITE': 'https://mailu.io',\n    'ADMIN' : 'none',\n    'WEB_ADMIN': '/admin',\n    'WEB_WEBMAIL': '/webmail',\n    'WEBMAIL': 'none',\n    'RECAPTCHA_PUBLIC_KEY': '',\n    'RECAPTCHA_PRIVATE_KEY': '',\n    'LOGO_URL': None,\n    'LOGO_BACKGROUND': None,\n    # Advanced settings\n    'LOG_LEVEL': 'WARNING',\n    'SESSION_KEY_BITS': 128,\n    'SESSION_LIFETIME': 24,\n    'SESSION_COOKIE_SECURE': True,\n    'CREDENTIAL_ROUNDS': 12,\n    'TZ': 'Etc/UTC',\n    # Host settings\n    'HOST_IMAP': 'imap',\n    'HOST_LMTP': 'imap:2525',\n    'HOST_POP3': 'imap',\n    'HOST_SMTP': 'smtp',\n    'HOST_AUTHSMTP': 'smtp',\n    'HOST_ADMIN': 'admin',\n    'HOST_WEBMAIL': 'webmail',\n    'HOST_WEBDAV': 'webdav:5232',\n    'HOST_REDIS': 'redis',\n    'HOST_FRONT': 'front',\n    'SUBNET': '192.168.203.0/24',\n    'SUBNET6': None,\n    'POD_ADDRESS_RANGE': None\n}\n\nclass ConfigManager(dict):\n    \"\"\" Naive configuration manager that uses environment only\n    \"\"\"\n\n    DB_TEMPLATES = {\n        'sqlite': 'sqlite:////{SQLITE_DATABASE_FILE}',\n        'postgresql': 'postgresql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}',\n        'mysql': 'mysql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}'\n    }\n\n    def __init__(self):\n        self.config = dict()\n\n    def get_host_address(self, name):\n        # if MYSERVICE_ADDRESS is defined, use this\n        if '{}_ADDRESS'.format(name) in os.environ:\n            return os.environ.get('{}_ADDRESS'.format(name))\n        # otherwise use the host name and resolve it\n        return system.resolve_address(self.config['HOST_{}'.format(name)])\n\n    def resolve_hosts(self):\n        self.config[\"IMAP_ADDRESS\"] = self.get_host_address(\"IMAP\")\n        self.config[\"POP3_ADDRESS\"] = self.get_host_address(\"POP3\")\n        self.config[\"AUTHSMTP_ADDRESS\"] = self.get_host_address(\"AUTHSMTP\")\n        self.config[\"SMTP_ADDRESS\"] = self.get_host_address(\"SMTP\")\n        self.config[\"REDIS_ADDRESS\"] = self.get_host_address(\"REDIS\")\n        if self.config[\"WEBMAIL\"] != \"none\":\n            self.config[\"WEBMAIL_ADDRESS\"] = self.get_host_address(\"WEBMAIL\")\n\n    def __get_env(self, key, value):\n        key_file = key + \"_FILE\"\n        if key_file in os.environ:\n            with open(os.environ.get(key_file)) as file:\n                value_from_file = file.read()\n            return value_from_file.strip()\n        else:\n            return os.environ.get(key, value)\n\n    def __coerce_value(self, value):\n        if isinstance(value, str) and value.lower() in ('true','yes'):\n            return True\n        elif isinstance(value, str) and value.lower() in ('false', 'no'):\n            return False\n        return value\n\n    def init_app(self, app):\n        self.config.update(app.config)\n        # get environment variables\n        self.config.update({\n            key: self.__coerce_value(self.__get_env(key, value))\n            for key, value in DEFAULT_CONFIG.items()\n        })\n        self.resolve_hosts()\n\n        # automatically set the sqlalchemy string\n        if self.config['DB_FLAVOR']:\n            template = self.DB_TEMPLATES[self.config['DB_FLAVOR']]\n            self.config['SQLALCHEMY_DATABASE_URI'] = template.format(**self.config)\n\n        self.config['RATELIMIT_STORAGE_URL'] = 'redis://{0}/2'.format(self.config['REDIS_ADDRESS'])\n        self.config['QUOTA_STORAGE_URL'] = 'redis://{0}/1'.format(self.config['REDIS_ADDRESS'])\n        self.config['SESSION_STORAGE_URL'] = 'redis://{0}/3'.format(self.config['REDIS_ADDRESS'])\n        self.config['SESSION_COOKIE_SAMESITE'] = 'Strict'\n        self.config['SESSION_COOKIE_HTTPONLY'] = True\n        self.config['PERMANENT_SESSION_LIFETIME'] = timedelta(hours=int(self.config['SESSION_LIFETIME']))\n        hostnames = [host.strip() for host in self.config['HOSTNAMES'].split(',')]\n        self.config['AUTH_RATELIMIT_EXEMPTION'] = set(ipaddress.ip_network(cidr, False) for cidr in (cidr.strip() for cidr in self.config['AUTH_RATELIMIT_EXEMPTION'].split(',')) if cidr)\n        self.config['HOSTNAMES'] = ','.join(hostnames)\n        self.config['HOSTNAME'] = hostnames[0]\n        # update the app config itself\n        app.config = self\n\n    def setdefault(self, key, value):\n        if key not in self.config:\n            self.config[key] = value\n        return self.config[key]\n\n    def get(self, *args):\n        return self.config.get(*args)\n\n    def keys(self):\n        return self.config.keys()\n\n    def __getitem__(self, key):\n        return self.config.get(key)\n\n    def __setitem__(self, key, value):\n        self.config[key] = value\n\n    def __contains__(self, key):\n        return key in self.config\n", "path": "core/admin/mailu/configuration.py"}]}