dev: update email templates for test email

This commit is contained in:
pablohashescobar 2024-05-14 12:30:20 +05:30
parent 7ca7b80c89
commit 9122d34e8b
2 changed files with 18 additions and 6 deletions

View File

@ -1,6 +1,9 @@
from django.core.mail import EmailMultiAlternatives, get_connection from django.core.mail import EmailMultiAlternatives, get_connection
from django.core.management import BaseCommand, CommandError from django.core.management import BaseCommand, CommandError
from django.template.loader import render_to_string
from django.utils.html import strip_tags
# Module imports
from plane.license.utils.instance_value import get_email_configuration from plane.license.utils.instance_value import get_email_configuration
@ -37,10 +40,10 @@ class Command(BaseCommand):
timeout=30, timeout=30,
) )
# Prepare email details # Prepare email details
subject = "Email Notification from Plane" subject = "Test email from Plane"
message = (
"This is a sample email notification sent from Plane application." html_content = render_to_string("emails/test_email.html")
) text_content = strip_tags(html_content)
self.stdout.write(self.style.SUCCESS("Trying to send test email...")) self.stdout.write(self.style.SUCCESS("Trying to send test email..."))
@ -48,11 +51,14 @@ class Command(BaseCommand):
try: try:
msg = EmailMultiAlternatives( msg = EmailMultiAlternatives(
subject=subject, subject=subject,
body=message, body=text_content,
from_email=EMAIL_FROM, from_email=EMAIL_FROM,
to=[receiver_email], to=[
receiver_email,
],
connection=connection, connection=connection,
) )
msg.attach_alternative(html_content, "text/html")
msg.send() msg.send()
self.stdout.write(self.style.SUCCESS("Email successfully sent")) self.stdout.write(self.style.SUCCESS("Email successfully sent"))
except Exception as e: except Exception as e:

View File

@ -0,0 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<p>This is a test email sent to verify if email configuration is working as expected in your Plane instance.</p>
<p>Regards,</br> Team Plane </p>
</html>