Fixed send mails #70
This commit is contained in:
parent
4869039503
commit
840193d5a8
@ -17,7 +17,7 @@
|
|||||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"cpl-core==2022.10.0.post7",
|
"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-query==2022.10.0.post2",
|
||||||
"cpl-discord==2022.10.0.post6",
|
"cpl-discord==2022.10.0.post6",
|
||||||
"Flask==2.2.2",
|
"Flask==2.2.2",
|
||||||
|
@ -154,6 +154,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"api": {
|
"api": {
|
||||||
|
"mail": {
|
||||||
|
"automatic_mail": "\n\nDies ist eine automatische E-Mail.\nGesendet von {}-{}@{}"
|
||||||
|
},
|
||||||
"api": {
|
"api": {
|
||||||
"test_mail": {
|
"test_mail": {
|
||||||
"subject": "Krümmelmonster Web Interface Test-Mail",
|
"subject": "Krümmelmonster Web Interface Test-Mail",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import re
|
import re
|
||||||
|
import textwrap
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@ -138,12 +139,13 @@ class AuthService(AuthServiceABC):
|
|||||||
|
|
||||||
mail = EMail()
|
mail = EMail()
|
||||||
mail.add_header('Mime-Version: 1.0')
|
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_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.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 = textwrap.dedent(f"""{self._t.transform('api.auth.confirmation.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}'
|
{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)
|
self._mailer.send_mail(mail)
|
||||||
|
|
||||||
def _send_forgot_password_id_to_user(self, user: AuthUser):
|
def _send_forgot_password_id_to_user(self, user: AuthUser):
|
||||||
@ -151,14 +153,17 @@ class AuthService(AuthServiceABC):
|
|||||||
if not url.endswith('/'):
|
if not url.endswith('/'):
|
||||||
url = f'{url}/'
|
url = f'{url}/'
|
||||||
|
|
||||||
|
# todo send mail in background task
|
||||||
|
# todo create cpl ticket to send mails async
|
||||||
mail = EMail()
|
mail = EMail()
|
||||||
mail.add_header('Mime-Version: 1.0')
|
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_header('Content-Transfer-Encoding: quoted-printable')
|
||||||
mail.add_receiver(user.email)
|
mail.add_receiver(str(user.email))
|
||||||
mail.subject = str(self._t.transform('api.auth.forgot_password.subject').format(user.first_name, user.last_name))
|
mail.subject = 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 = textwrap.dedent(f"""{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}'
|
{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)
|
self._mailer.send_mail(mail)
|
||||||
|
|
||||||
async def get_all_auth_users_async(self) -> List[AuthUserDTO]:
|
async def get_all_auth_users_async(self) -> List[AuthUserDTO]:
|
||||||
|
Loading…
Reference in New Issue
Block a user