mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-03 16:41:27 +01:00
18 lines
692 B
Python
18 lines
692 B
Python
import ssl
|
|
from django.core.mail.backends.smtp import EmailBackend
|
|
from django.conf import settings
|
|
|
|
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
|