diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index f7fdb2cfc5..8b89b5b0f9 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -17,7 +17,7 @@ "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ "cpl-core==2022.10.0.post7", - "cpl-translation==2022.10.0.post1", + "cpl-translation==2022.10.0.post2", "cpl-query==2022.10.0.post2", "cpl-discord==2022.10.0.post6", "Flask==2.2.2", diff --git a/kdb-bot/src/bot/translation/de.json b/kdb-bot/src/bot/translation/de.json index 7850782ca2..206df3ea17 100644 --- a/kdb-bot/src/bot/translation/de.json +++ b/kdb-bot/src/bot/translation/de.json @@ -154,6 +154,9 @@ } }, "api": { + "mail": { + "automatic_mail": "\n\nDies ist eine automatische E-Mail.\nGesendet von {}-{}@{}" + }, "api": { "test_mail": { "subject": "Krümmelmonster Web Interface Test-Mail", diff --git a/kdb-bot/src/bot_api/service/auth_service.py b/kdb-bot/src/bot_api/service/auth_service.py index 15fa8138cc..94f8830047 100644 --- a/kdb-bot/src/bot_api/service/auth_service.py +++ b/kdb-bot/src/bot_api/service/auth_service.py @@ -1,5 +1,6 @@ import hashlib import re +import textwrap import uuid from datetime import datetime, timedelta, timezone from typing import Optional @@ -138,12 +139,13 @@ class AuthService(AuthServiceABC): mail = EMail() mail.add_header('Mime-Version: 1.0') - mail.add_header('Content-Type: text/plain charset=utf-8') + mail.add_header('Content-Type: text/plain; charset=utf-8') mail.add_header('Content-Transfer-Encoding: quoted-printable') - mail.add_receiver(user.email) + mail.add_receiver(str(user.email)) mail.subject = self._t.transform('api.auth.confirmation.subject').format(user.first_name, user.last_name) - mail.body = self._t.transform('api.auth.confirmation.message').format(url, user.confirmation_id) - mail.body += f'\n\nDies ist eine automatische E-Mail.\nGesendet von {self._environment.application_name}-{self._environment.environment_name}@{self._environment.host_name}' + mail.body = textwrap.dedent(f"""{self._t.transform('api.auth.confirmation.message').format(url, user.forgot_password_id)} + {self._t.transform('api.mail.automatic_mail').format(self._environment.application_name, self._environment.environment_name, self._environment.host_name)} + """) self._mailer.send_mail(mail) def _send_forgot_password_id_to_user(self, user: AuthUser): @@ -151,14 +153,17 @@ class AuthService(AuthServiceABC): if not url.endswith('/'): url = f'{url}/' + # todo send mail in background task + # todo create cpl ticket to send mails async mail = EMail() mail.add_header('Mime-Version: 1.0') - mail.add_header('Content-Type: text/plain charset=utf-8') + mail.add_header('Content-Type: text/plain; charset=utf-8') mail.add_header('Content-Transfer-Encoding: quoted-printable') - mail.add_receiver(user.email) - mail.subject = str(self._t.transform('api.auth.forgot_password.subject').format(user.first_name, user.last_name)) - mail.body = str(self._t.transform('api.auth.forgot_password.message').format(url, user.forgot_password_id)) - mail.body += f'\n\nDies ist eine automatische E-Mail.\nGesendet von {self._environment.application_name}-{self._environment.environment_name}@{self._environment.host_name}' + mail.add_receiver(str(user.email)) + mail.subject = self._t.transform('api.auth.forgot_password.subject').format(user.first_name, user.last_name) + mail.body = textwrap.dedent(f"""{self._t.transform('api.auth.forgot_password.message').format(url, user.forgot_password_id)} + {self._t.transform('api.mail.automatic_mail').format(self._environment.application_name, self._environment.environment_name, self._environment.host_name)} + """) self._mailer.send_mail(mail) async def get_all_auth_users_async(self) -> List[AuthUserDTO]: