From b33197896412889b6fdb1ae5839155cd04b1ee06 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 2 Oct 2020 14:55:28 -0700 Subject: [PATCH] email sender --- bookwyrm/emailing.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bookwyrm/emailing.py diff --git a/bookwyrm/emailing.py b/bookwyrm/emailing.py new file mode 100644 index 00000000..12dee65f --- /dev/null +++ b/bookwyrm/emailing.py @@ -0,0 +1,26 @@ +''' send emails ''' +from django.core.mail import send_mail + +from bookwyrm import models +from bookwyrm.tasks import app + +def password_reset_email(reset_code): + ''' generate a password reset email ''' + # TODO; this should be tempalted + site = models.SiteSettings.get() + send_email.delay( + reset_code.user.email, + 'Reset your password on %s' % site.name, + 'Your password reset link: %s' % reset_code.link + ) + +@app.task +def send_email(recipient, subject, message): + ''' use a task to send the email ''' + send_mail( + subject, + message, + None, # sender will be the config default + [recipient], + fail_silently=False + )