-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
Today I accidentally sent emails from our dev environment as I misunderstood the SENDGRID_SANDBOX_MODE_IN_DEBUG setting. Unfortunately, it's currently not easily possible to enable the sandbox without setting DEBUG=True as well.
As a workaround, I'm now using a new email Backend on our dev environment that sets sandbox mode. Maybe consider adding this, or a setting like SENDGRID_SANDBOX_MODE which does not depend on the value of other settings.
from sendgrid_backend import SendgridBackend
class SandboxSendgridBackend(SendgridBackend):
"""
SendGrid backend that always enables sandbox mode.
This prevents actual email delivery in non-production environments
like QA and dev, regardless of DEBUG setting.
Sandbox mode causes SendGrid to validate the email but not send it,
making it safe to test email functionality without spamming users.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Always enable sandbox mode, overriding parent class logic
self.sandbox_mode = TrueMetadata
Metadata
Assignees
Labels
No labels