Fixes sending invite emails

Corrects the email sender and avoids integrity error on saves
This commit is contained in:
Mouse Reeve
2021-03-29 08:33:12 -07:00
parent fd97b167e1
commit f63b6fb325
4 changed files with 9 additions and 6 deletions

View File

@ -2,7 +2,7 @@
from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from bookwyrm import models
from bookwyrm import models, settings
from bookwyrm.tasks import app
from bookwyrm.settings import DOMAIN
@ -59,6 +59,8 @@ def format_email(email_name, data):
@app.task
def send_email(recipient, subject, html_content, text_content):
""" use a task to send the email """
email = EmailMultiAlternatives(subject, text_content, None, [recipient])
email = EmailMultiAlternatives(
subject, text_content, settings.DEFAULT_FROM_EMAIL, [recipient]
)
email.attach_alternative(html_content, "text/html")
email.send()