Add email sending task
This commit is contained in:
parent
6978bbd03e
commit
4569744726
1
Pipfile
1
Pipfile
@ -24,6 +24,7 @@ redis = "*"
|
|||||||
django-redis-cache = "*"
|
django-redis-cache = "*"
|
||||||
pycountry = "*"
|
pycountry = "*"
|
||||||
ipaddress = "*"
|
ipaddress = "*"
|
||||||
|
html2text = "*"
|
||||||
|
|
||||||
[pipenv]
|
[pipenv]
|
||||||
allow_prereleases = true
|
allow_prereleases = true
|
||||||
|
10
Pipfile.lock
generated
10
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "75fe7f0efbc05d6bc32c5ccaa08d3d619bf925682ca5eaffa728e74d0e8e5f66"
|
"sha256": "e66668cad32f92f11324d92caa0e3e83afcb3cafe471f3ba1f178fc090dd7b6b"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {},
|
"requires": {},
|
||||||
@ -118,6 +118,14 @@
|
|||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==20.0.4"
|
"version": "==20.0.4"
|
||||||
},
|
},
|
||||||
|
"html2text": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:c7c629882da0cf377d66f073329ccf34a12ed2adf0169b9285ae4e63ef54c82b",
|
||||||
|
"sha256:e296318e16b059ddb97f7a8a1d6a5c1d7af4544049a01e261731d2d5cc277bbb"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==2020.1.16"
|
||||||
|
},
|
||||||
"idna": {
|
"idna": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
|
"sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
|
||||||
|
16
shynet/dashboard/tasks.py
Normal file
16
shynet/dashboard/tasks.py
Normal 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,
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user