from django.core import mail from django.template.loader import render_to_string from django.utils.html import strip_tags from la_chariotte import settings def send_order_confirmation_mail(order): template_name = "mail/order_confirm_mail.html" subject = f"[La Chariotte] Votre commande pour {order.grouped_order.name}" html_message = render_to_string( template_name, {"order": order, "base_url": settings.BASE_URL} ) plain_message = strip_tags(html_message) from_email = "notification@chariotte.fr" to = order.author.email mail.send_mail(subject, plain_message, from_email, [to], html_message=html_message)