From 1bb6c99626656d1e2367a6073d3a8204c11d0f40 Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Fri, 14 Sep 2018 13:11:49 +0200
Subject: [PATCH] Remove SMTPHandler

Errors are now sent to sentry.
No need to send them directly via e-mail.

JIRA INFRA-525
---
 app/factory.py  | 28 ----------------------------
 app/settings.py |  4 ----
 2 files changed, 32 deletions(-)

diff --git a/app/factory.py b/app/factory.py
index f311666..8d11576 100644
--- a/app/factory.py
+++ b/app/factory.py
@@ -69,33 +69,6 @@ def create_app(config=None):
         )
 
     if not app.debug:
-        # Send ERROR via mail
-        from logging.handlers import SMTPHandler
-
-        mail_handler = SMTPHandler(
-            app.config["MAIL_SERVER"],
-            fromaddr=app.config["EMAIL_SENDER"],
-            toaddrs=app.config["ADMIN_EMAILS"],
-            subject="CSEntry: ERROR raised",
-            credentials=app.config["MAIL_CREDENTIALS"],
-        )
-        mail_handler.setFormatter(
-            logging.Formatter(
-                """
-            Message type:       %(levelname)s
-            Location:           %(pathname)s:%(lineno)d
-            Module:             %(module)s
-            Function:           %(funcName)s
-            Time:               %(asctime)s
-
-            Message:
-
-            %(message)s
-        """
-            )
-        )
-        mail_handler.setLevel(logging.ERROR)
-        app.logger.addHandler(mail_handler)
         # Log to stderr
         handler = logging.StreamHandler()
         handler.setFormatter(
@@ -118,7 +91,6 @@ def create_app(config=None):
             "SENTRY_DSN",
             "SECRET_KEY",
             "LDAP_BIND_USER_PASSWORD",
-            "MAIL_CREDENTIALS",
             "SQLALCHEMY_DATABASE_URI",
         )
     ]
diff --git a/app/settings.py b/app/settings.py
index 5e6eb49..7cb81e0 100644
--- a/app/settings.py
+++ b/app/settings.py
@@ -21,10 +21,6 @@ SECRET_KEY = (
     os.environ.get("SECRET_KEY")
     or b"\x0d\x11{\xd3\x13$\xeeel\xa6\xfb\x1d~\xfd\xb2\x9d\x16\x00\xfb5\xd64\xd4\xe0"
 )
-MAIL_SERVER = "mail.esss.lu.se"
-MAIL_CREDENTIALS = None
-ADMIN_EMAILS = ["admin@example.com"]
-EMAIL_SENDER = "noreply@esss.se"
 
 JWT_BLACKLIST_ENABLED = True
 JWT_BLACKLIST_TOKEN_CHECKS = ["access", "refresh"]
-- 
GitLab