Guest User

Untitled

a guest
Jun 2nd, 2020
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Таска
  2. @celery_app.task
  3. def send_email_for_reset_password(email_message):
  4. email_message.send()
  5.  
  6. Форма
  7. def send_mail(self, subject_template_name, email_template_name,
  8. context, from_email, to_email, html_email_template_name=None):
  9. """
  10. Send a django.core.mail.EmailMultiAlternatives to `to_email`.
  11. """
  12. subject = loader.render_to_string(subject_template_name, context)
  13. # Email subject *must not* contain newlines
  14. subject = ''.join(subject.splitlines())
  15. body = loader.render_to_string(email_template_name, context)
  16.  
  17. email_message = EmailMultiAlternatives(subject, body, from_email, [to_email])
  18. if html_email_template_name is not None:
  19. html_email = loader.render_to_string(html_email_template_name, context)
  20. email_message.attach_alternative(html_email, 'text/html')
  21.  
  22. send_email_for_reset_password.delay(email)
Add Comment
Please, Sign In to add comment