Files
holy-flavor-rater/backend/api/email_backend.py
T
2026-04-11 10:37:49 +02:00

21 lines
695 B
Python

import ssl
from django.conf import settings
from django.core.mail.backends.smtp import EmailBackend
class InsecureEmailBackend(EmailBackend):
"""
SMTP email backend that allows skipping SSL certificate verification.
Useful for local development or internal SMTP servers with self-signed certificates.
Set EMAIL_SKIP_CERT_VERIFICATION = True in settings to use.
"""
@property
def ssl_context(self):
if getattr(settings, "EMAIL_SKIP_CERT_VERIFICATION", False):
# The most robust way to bypass verification for self-signed certs
context = ssl._create_unverified_context()
return context
return super().ssl_context