mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-01 11:22:24 +02:00
21 lines
683 B
Python
21 lines
683 B
Python
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"[{settings.PROJECT_NAME}] 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 = settings.DEFAULT_FROM_EMAIL
|
|
to = order.author.email
|
|
|
|
mail.send_mail(subject, plain_message, from_email, [to], html_message=html_message)
|