diff --git a/.env.prod-sample b/.env.prod-sample index 3188451..0c6f7fa 100644 --- a/.env.prod-sample +++ b/.env.prod-sample @@ -12,10 +12,11 @@ POSTGRES_DB=forest_prod DATABASE_URL=postgresql://forest:forest123@db:5432/forest_prod +MAIL_ADMIN=daniel@deflax.net +MAIL_SUBJECT_PREFIX=ForestNet + MAIL_SERVER=smtp.gmail.com MAIL_USERNAME=admin@gmail.com MAIL_PASSWORD=kur MAIL_PORT=25 -MAIL_SUBJECT_PREFIX=ForestNet -MAIL_ADMIN=daniel@deflax.net MAIL_USE_TLS=1 \ No newline at end of file diff --git a/flask/forest/__init__.py b/flask/forest/__init__.py index 9fb7d9c..68ba790 100644 --- a/flask/forest/__init__.py +++ b/flask/forest/__init__.py @@ -105,26 +105,5 @@ def service_unavailable(e): def handle_csrf_error(e): return render_template('errors/csrf_error.html', reason=e.description), 400 - -if not app.config['DEBUG'] == 1 and app.config['MAIL_SERVER'] != '': - import logging - from logging.handlers import SMTPHandler - credentials = None - secure = None - if app.config['MAIL_USERNAME'] or app.config['MAIL_PASSWORD']: - credentials = (app.config['MAIL_USERNAME'], app.config['MAIL_PASSWORD']) - if app.config['MAIL_USE_TLS'] is None: - secure = () - mail_handler = SMTPHandler( - mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']), - fromaddr=app.config['MAIL_SENDER'], - toaddrs=[app.config['MAIL_ADMIN']], - subject=app.config['MAIL_SUBJECT_PREFIX'] + ' Application Error', - credentials=credentials, - secure=secure) - mail_handler.setLevel(logging.ERROR) - app.logger.addHandler(mail_handler) - - if __name__ == '__main__': app.run() diff --git a/flask/forest/email.py b/flask/forest/email.py index e54bf38..b3ba599 100644 --- a/flask/forest/email.py +++ b/flask/forest/email.py @@ -15,7 +15,7 @@ def send_email(to, subject, template, **kwargs): else: newsubject = subject app = current_app._get_current_object() - msg = Message(app.config['MAIL_SUBJECT_PREFIX'] + ' ' + newsubject, sender=app.config['MAIL_SENDER'], recipients=[to]) + msg = Message(app.config['MAIL_SUBJECT_PREFIX'] + ' ' + newsubject, sender=app.config['MAIL_ADMIN'], recipients=[to]) msg.body = render_template(template + '.txt', **kwargs) msg.html = render_template(template + '.html', **kwargs) thr = Thread(target=send_async_email, args=[app, msg])