add email templates

This commit is contained in:
knst-kotov 2022-06-23 12:57:07 +03:00
parent bb96dc00a6
commit f36db24bad
4 changed files with 15 additions and 3 deletions

View File

@ -12,18 +12,27 @@ MAILGUN_FROM = "postmaster <postmaster@%s>" % (MAILGUN_DOMAIN)
AUTH_URL = "%s/email_authorize" % (BACKEND_URL)
email_templates = {"confirm_email" : "", "auth_email" : "", "reset_password_email" : ""}
def load_email_templates():
for name in email_templates:
filename = "templates/%s.tmpl" % name
with open(filename) as f:
email_templates[name] = f.read()
print("all email templates loaded")
async def send_confirm_email(user):
text = "<html><body>To confirm registration follow the <a href='%s'>link</link></body></html>"
text = email_templates["confirm_email"]
token = await EmailAuthenticate.get_email_token(user)
await send_email(user, AUTH_URL, text, token)
async def send_auth_email(user):
text = "<html><body>To enter the site follow the <a href='%s'>link</link></body></html>"
text = email_templates["auth_email"]
token = await EmailAuthenticate.get_email_token(user)
await send_email(user, AUTH_URL, text, token)
async def send_reset_password_email(user):
text = "<html><body>To reset password follow the <a href='%s'>link</link></body></html>"
text = email_templates["reset_password_email"]
token = await ResetPassword.get_reset_token(user)
await send_email(user, RESET_PWD_URL, text, token)

View File

@ -0,0 +1 @@
<html><body>To enter the site follow the <a href='%s'>link</link></body></html>

View File

@ -0,0 +1 @@
<html><body>To confirm registration follow the <a href='%s'>link</link></body></html>

View File

@ -0,0 +1 @@
<html><body>To reset password follow the <a href='%s'>link</link></body></html>