diff --git a/apiserver/plane/db/management/commands/test_email.py b/apiserver/plane/db/management/commands/test_email.py index 63b602518..facea7e9c 100644 --- a/apiserver/plane/db/management/commands/test_email.py +++ b/apiserver/plane/db/management/commands/test_email.py @@ -1,6 +1,9 @@ from django.core.mail import EmailMultiAlternatives, get_connection 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 @@ -37,10 +40,10 @@ class Command(BaseCommand): timeout=30, ) # Prepare email details - subject = "Email Notification from Plane" - message = ( - "This is a sample email notification sent from Plane application." - ) + subject = "Test email from Plane" + + 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...")) @@ -48,11 +51,14 @@ class Command(BaseCommand): try: msg = EmailMultiAlternatives( subject=subject, - body=message, + body=text_content, from_email=EMAIL_FROM, - to=[receiver_email], + to=[ + receiver_email, + ], connection=connection, ) + msg.attach_alternative(html_content, "text/html") msg.send() self.stdout.write(self.style.SUCCESS("Email successfully sent")) except Exception as e: diff --git a/apiserver/templates/emails/test_email.html b/apiserver/templates/emails/test_email.html new file mode 100644 index 000000000..4e4d3d940 --- /dev/null +++ b/apiserver/templates/emails/test_email.html @@ -0,0 +1,6 @@ + + +

This is a test email sent to verify if email configuration is working as expected in your Plane instance.

+ +

Regards,
Team Plane

+ \ No newline at end of file