You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
566 B

  1. from django.conf import settings
  2. from django.core.mail import send_mail
  3. from django.template.loader import render_to_string
  4. def send(to, template_directory, ctx):
  5. """ Send HTML email using Mandrill.
  6. Expect template_directory to be a path containing
  7. - subject.txt
  8. - body.html
  9. """
  10. from_email = settings.DEFAULT_FROM_EMAIL
  11. subject = render_to_string("%s/subject.txt" % template_directory, ctx)
  12. body = render_to_string("%s/body.html" % template_directory, ctx)
  13. send_mail(subject, "", from_email, [to], html_message=body)