Fixed send mails #70

This commit is contained in:
2022-10-19 18:01:11 +02:00
parent 4869039503
commit 840193d5a8
3 changed files with 18 additions and 10 deletions

View File

@@ -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]: