Conditionally support email; email host is now a setting rather than hard coded.
authorBryan <btbonval@gmail.com>
Tue, 14 Jan 2014 04:08:11 +0000 (23:08 -0500)
committerBryan <btbonval@gmail.com>
Tue, 14 Jan 2014 04:08:11 +0000 (23:08 -0500)
karmaworld/secret/email.py.example
karmaworld/settings/prod.py

index c0f726f94f77923158f20316a75be3b773d7bae4..1aba88a18ca0f76679458459b786982ce8ba1fdd 100644 (file)
@@ -1,4 +1,5 @@
 
+STMP_HOST = ''
 SMTP_USERNAME = ''
 SMTP_PASSWORD = ''
 
index 88f2ca53403f334942f63024d29cd8266166cb9f..1bd651f9c948ebcb70a10b394a0099b0391ab2d9 100644 (file)
@@ -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