From: Bryan Date: Tue, 14 Jan 2014 04:08:11 +0000 (-0500) Subject: Conditionally support email; email host is now a setting rather than hard coded. X-Git-Tag: release-20150131~240^2~14 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a46b442e07c9be15b3c1c8f27b4bc16fcc99f958;p=oweals%2Fkarmaworld.git Conditionally support email; email host is now a setting rather than hard coded. --- diff --git a/karmaworld/secret/email.py.example b/karmaworld/secret/email.py.example index c0f726f..1aba88a 100644 --- a/karmaworld/secret/email.py.example +++ b/karmaworld/secret/email.py.example @@ -1,4 +1,5 @@ +STMP_HOST = '' SMTP_USERNAME = '' SMTP_PASSWORD = '' diff --git a/karmaworld/settings/prod.py b/karmaworld/settings/prod.py index 88f2ca5..1bd651f 100644 --- a/karmaworld/settings/prod.py +++ b/karmaworld/settings/prod.py @@ -22,35 +22,42 @@ from karmaworld.secret.db_settings import PROD_DB_NAME from karmaworld.secret.db_settings import PROD_DB_USERNAME from karmaworld.secret.db_settings import PROD_DB_PASSWORD -from karmaworld.secret.email import SMTP_USERNAME -from karmaworld.secret.email import SMTP_PASSWORD +try: + # Include email is settings are there + from karmaworld.secret.email import SMTP_HOST + from karmaworld.secret.email import SMTP_USERNAME + from karmaworld.secret.email import SMTP_PASSWORD + EMAIL = True +except: + EMAIL = False ########## EMAIL CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host -EMAIL_HOST = environ.get('EMAIL_HOST', 'email-smtp.us-east-1.amazonaws.com') - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password -EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD) - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user -EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME) - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port -EMAIL_PORT = environ.get('EMAIL_PORT', 587) - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix -EMAIL_SUBJECT_PREFIX = 'KarmaNotes ' - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls -EMAIL_USE_TLS = True - -DEFAULT_FROM_EMAIL = 'info@karmanotes.org' - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email -SERVER_EMAIL = EMAIL_HOST_USER +if EMAIL: + # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend + EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' + + # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host + EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST) + + # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password + EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD) + + # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user + EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME) + + # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port + EMAIL_PORT = environ.get('EMAIL_PORT', 587) + + # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix + EMAIL_SUBJECT_PREFIX = 'KarmaNotes ' + + # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls + EMAIL_USE_TLS = True + + DEFAULT_FROM_EMAIL = 'info@karmanotes.org' + + # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email + SERVER_EMAIL = EMAIL_HOST_USER ########## END EMAIL CONFIGURATION