2021-03-08 16:49:10 +00:00
|
|
|
""" send emails """
|
2020-10-02 21:55:28 +00:00
|
|
|
from django.core.mail import send_mail
|
|
|
|
|
|
|
|
from bookwyrm import models
|
|
|
|
from bookwyrm.tasks import app
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2020-10-02 21:55:28 +00:00
|
|
|
def password_reset_email(reset_code):
|
2021-03-08 16:49:10 +00:00
|
|
|
""" generate a password reset email """
|
2020-10-02 21:55:28 +00:00
|
|
|
site = models.SiteSettings.get()
|
|
|
|
send_email.delay(
|
|
|
|
reset_code.user.email,
|
2021-03-08 16:49:10 +00:00
|
|
|
"Reset your password on %s" % site.name,
|
|
|
|
"Your password reset link: %s" % reset_code.link,
|
2020-10-02 21:55:28 +00:00
|
|
|
)
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2020-10-02 21:55:28 +00:00
|
|
|
@app.task
|
|
|
|
def send_email(recipient, subject, message):
|
2021-03-08 16:49:10 +00:00
|
|
|
""" use a task to send the email """
|
2020-10-02 21:55:28 +00:00
|
|
|
send_mail(
|
|
|
|
subject,
|
|
|
|
message,
|
2021-03-08 16:49:10 +00:00
|
|
|
None, # sender will be the config default
|
2020-10-02 21:55:28 +00:00
|
|
|
[recipient],
|
2021-03-08 16:49:10 +00:00
|
|
|
fail_silently=False,
|
2020-10-02 21:55:28 +00:00
|
|
|
)
|