Add email sending task

This commit is contained in:
R. Miles McCain
2020-05-09 12:35:50 -04:00
parent 6978bbd03e
commit 4569744726
3 changed files with 26 additions and 1 deletions

16
shynet/dashboard/tasks.py Normal file
View File

@@ -0,0 +1,16 @@
from celery import shared_task
from django.core import mail
from django.conf import settings
import html2text
@shared_task
def send_email(to: [str], subject: str, content: str, from_email: str = None):
text_content = html2text.html2text(content)
mail.send_mail(
subject,
text_content,
from_email or settings.DEFAULT_FROM_EMAIL,
to,
html_message=content,
)