Send branded HTML emails and harden SMTP2GO webhooks.
Deploy Beta / unit-tests (push) Successful in 9s
Deploy Beta / docker (push) Successful in 15s
Deploy Beta / deploy-beta (push) Successful in 1m36s

Fix campaign stuck on sending under async queue, and stop UUID ValidationError when SMTP2GO tests send "Headers Unavailable".
This commit is contained in:
2026-08-09 06:37:20 -05:00
parent 617bda3e8b
commit d830f07757
16 changed files with 558 additions and 63 deletions
+15 -11
View File
@@ -3,10 +3,12 @@
import logging
from django.conf import settings
from django.core.mail import EmailMessage
from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from django.urls import reverse
from leads.models import Lead
from public.email_branding import email_brand_context
logger = logging.getLogger(__name__)
@@ -49,23 +51,25 @@ def notify_admins_of_contact_form(lead: Lead) -> bool:
]
address = "\n".join(bit for bit in address_bits if bit) or "(none)"
body = (
f"New contact form inquiry from {name}.\n\n"
f"Name: {name}\n"
f"Email: {email}\n"
f"Phone: {phone}\n"
f"Address:\n{address}\n\n"
f"Message:\n{message}\n\n"
f"View in portal: {portal_url}\n"
ctx = email_brand_context(
name=name,
email=email,
phone=phone,
address=address,
message=message,
portal_url=portal_url,
)
text_content = get_template("emails/contact_email.txt").render(ctx)
html_content = get_template("emails/contact_email.html").render(ctx)
mail = EmailMessage(
mail = EmailMultiAlternatives(
subject=f"New contact form inquiry from {name}",
body=body,
body=text_content,
from_email=settings.DEFAULT_FROM_EMAIL,
to=[to_email],
reply_to=[contact.email] if contact.email else None,
)
mail.attach_alternative(html_content, "text/html")
try:
mail.send(fail_silently=False)
except Exception: