forked from Hostea/dashboard
feat: verification link email template with polished email body
parent
4a1c0a5cdc
commit
63f4f987a9
|
@ -0,0 +1,9 @@
|
|||
Hello {{ username }},
|
||||
|
||||
Please click on the link below to verify your email.
|
||||
{{ link }}
|
||||
|
||||
If you don't recognise this activity, please delete this mail.
|
||||
|
||||
Cheers,
|
||||
Hostea team
|
|
@ -17,6 +17,7 @@ from datetime import datetime, timezone
|
|||
from django.utils.crypto import get_random_string
|
||||
from django.core.mail import send_mail
|
||||
from django.shortcuts import redirect
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from django.utils.http import urlencode
|
||||
from django.conf import settings
|
||||
|
@ -34,12 +35,24 @@ def send_verification_email(request, challenge):
|
|||
f"{request.scheme}://{request.get_host()}{challenge.verification_link()}"
|
||||
)
|
||||
|
||||
ctx = {
|
||||
"link": verification_link,
|
||||
"username": challenge.owned_by.username,
|
||||
}
|
||||
|
||||
body = render_to_string(
|
||||
"accounts/emails/verification-link.txt",
|
||||
context=ctx,
|
||||
)
|
||||
|
||||
email = challenge.owned_by.email
|
||||
|
||||
sender = settings.HOSTEA["EMAIL_SENDER_ADDRESS"]
|
||||
|
||||
send_mail(
|
||||
subject="[Hostea] Please confirm your email address",
|
||||
message=f"Please confirm your email address {email}.\n {verification_link}",
|
||||
from_email="No reply Hostea<no-reply@exampl.org>", # TODO read from settings.py
|
||||
message=body,
|
||||
from_email=f"No reply Hostea<{sender}>", # TODO read from settings.py
|
||||
recipient_list=[email],
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue