From 663da57d8beb768580c07624ea9d7d590f4c429d Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Fri, 5 Jun 2020 13:54:37 -0600 Subject: [PATCH] Config can read smtp values from environment now --- config/default.py | 8 +++++++- crc/__init__.py | 6 ------ crc/services/mails.py | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/config/default.py b/config/default.py index bac744fd..ae17bcfa 100644 --- a/config/default.py +++ b/config/default.py @@ -44,5 +44,11 @@ PB_STUDY_DETAILS_URL = environ.get('PB_STUDY_DETAILS_URL', default=PB_BASE_URL + LDAP_URL = environ.get('LDAP_URL', default="ldap.virginia.edu").strip('/') # No trailing slash or http:// LDAP_TIMEOUT_SEC = int(environ.get('LDAP_TIMEOUT_SEC', default=3)) -# Fallback emails +# Email configuration FALLBACK_EMAILS = ['askresearch@virginia.edu', 'sartographysupport@googlegroups.com'] +MAIL_SERVER = environ.get('MAIL_SERVER', default='smtp.mailtrap.io') +MAIL_PORT = environ.get('MAIL_PORT', default=2525) +MAIL_USE_SSL = environ.get('MAIL_USE_SSL', default=False) +MAIL_USE_TLS = environ.get('MAIL_USE_TLS', default=True) +MAIL_USERNAME = environ.get('MAIL_USERNAME', default='5f012d0108d374') +MAIL_PASSWORD = environ.get('MAIL_PASSWORD', default='08442c04e98d50') diff --git a/crc/__init__.py b/crc/__init__.py index 66b91b63..e77864b9 100644 --- a/crc/__init__.py +++ b/crc/__init__.py @@ -54,12 +54,6 @@ if app.config['ENABLE_SENTRY']: template_dir = os.getcwd() + '/crc/static/templates/mails' env = Environment(loader=FileSystemLoader(template_dir)) # Mail settings -app.config['MAIL_SERVER']='smtp.mailtrap.io' -app.config['MAIL_PORT'] = 2525 -app.config['MAIL_USERNAME'] = '5f012d0108d374' -app.config['MAIL_PASSWORD'] = '08442c04e98d50' -app.config['MAIL_USE_TLS'] = True -app.config['MAIL_USE_SSL'] = False mail = Mail(app) print('=== USING THESE CONFIG SETTINGS: ===') diff --git a/crc/services/mails.py b/crc/services/mails.py index 2a80457c..994914d4 100644 --- a/crc/services/mails.py +++ b/crc/services/mails.py @@ -59,6 +59,7 @@ def send_ramp_up_approved_email(sender, recipients, approver_1, approver_2=None) msg = Message('Research Ramp-up Plan Approved', sender=sender, recipients=recipients) + from crc import env, mail template = env.get_template('ramp_up_approved.txt') template_vars = {'approver_1': approver_1, 'approver_2': approver_2}