From 2f52b3272db0d06b6b40f5be6ec3b13b87852922 Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Fri, 8 Sep 2017 13:40:50 +0200
Subject: [PATCH] Add variable to pass SMTP server credentials

---
 app/factory.py  | 7 ++++---
 app/settings.py | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/app/factory.py b/app/factory.py
index dd2474e..7ffe7fc 100644
--- a/app/factory.py
+++ b/app/factory.py
@@ -49,9 +49,10 @@ def create_app(config=None):
         # Send ERROR via mail
         from logging.handlers import SMTPHandler
         mail_handler = SMTPHandler(app.config['MAIL_SERVER'],
-                                   app.config['EMAIL_SENDER'],
-                                   app.config['ADMIN_EMAILS'],
-                                   'Inventory: ERROR raised')
+                                   fromaddr=app.config['EMAIL_SENDER'],
+                                   toaddrs=app.config['ADMIN_EMAILS'],
+                                   subject='Inventory: ERROR raised',
+                                   credentials=app.config['MAIL_CREDENTIALS'])
         mail_handler.setFormatter(logging.Formatter("""
             Message type:       %(levelname)s
             Location:           %(pathname)s:%(lineno)d
diff --git a/app/settings.py b/app/settings.py
index 1567bde..3a7cc2a 100644
--- a/app/settings.py
+++ b/app/settings.py
@@ -18,8 +18,9 @@ BOOTSTRAP_SERVE_LOCAL = True
 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 = 'inventory@esss.se'
+EMAIL_SENDER = 'noreply@esss.se'
 
 JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=12)
 
-- 
GitLab