Email backend: don't barf on the screen

This commit is contained in:
Klaas van Schelven
2024-08-28 14:23:28 +02:00
parent 14ffbb7a48
commit ea5ac848fc
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ if os.getenv("EMAIL_HOST"):
EMAIL_USE_TLS = os.getenv("EMAIL_USE_TLS", "True").lower() in ("true", "1", "yes")
else:
# print("WARNING: EMAIL_HOST not set; email will not be sent")
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
EMAIL_BACKEND = "bugsink.email_backends.QuietConsoleEmailBackend"
SERVER_EMAIL = DEFAULT_FROM_EMAIL = os.getenv("DEFAULT_FROM_EMAIL", "Bugsink <bugsink@example.org>")
+10
View File
@@ -0,0 +1,10 @@
from django.core.mail.backends.console import EmailBackend as ConsoleEmailBackend
class QuietConsoleEmailBackend(ConsoleEmailBackend):
def write_message(self, message):
msg = message.message()
# self.stream.write("From: %s\n" % msg["From"])
# self.stream.write("To: %s\n" % msg["To"])
self.stream.write("Mail not sent (not SMTP configured); Subject: %s\n" % msg["Subject"])