If EMAIL_HOST is unset or blank, don't send email via django.core.mail

It will instead use the dummy EmailBackend

(imported from commit 6faec7f3e087901226a120b9268cf687ed165c05)
This commit is contained in:
acrefoot
2013-11-04 19:19:52 -05:00
parent bdbd8d006a
commit 4c88a909cb
3 changed files with 13 additions and 5 deletions

View File

@@ -38,11 +38,12 @@ MANDRILL_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxx'
# This should be synced with our camo installation
CAMO_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
EMAIL_USE_TLS = True
# Leave EMAIL_HOST unset or empty if you do not wish for emails to be sent
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'zulip@zulip.com'
EMAIL_HOST_PASSWORD = 'xxxxxxxxxxxxxxxx'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
config_file = ConfigParser.RawConfigParser()
config_file.read("/etc/zulip/zulip.conf")

View File

@@ -13,12 +13,13 @@ DEPLOYMENT_ROLE_KEY = ''
# Configure the outgoing SMTP server below. For outgoing email
# via a GMail SMTP server, EMAIL_USE_TLS must be True and the
# outgoing port must be 587. The EMAIL_HOST is prepopulated
# for GMail servers, change it for other hosts
EMAIL_USE_TLS = True
# for GMail servers, change it for other hosts, or leave it unset
# or empty to skip sending email.
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 587
EMAIL_USE_TLS = True
# By default uploaded files and avatars are stored directly on the Zulip server
# If file storage to Amazon S3 is desired, please contact Zulip Support

View File

@@ -670,10 +670,16 @@ if DEPLOYED:
else:
FULL_NAVBAR = True
# If an email host is not specified, fail silently and gracefully
if not EMAIL_HOST and DEPLOYED:
EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
elif not DEPLOYED:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
else:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# For testing, you may want to have emails be printed to the console.
if not DEPLOYED:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Use fast password hashing for creating testing users when not
# DEPLOYED
PASSWORD_HASHERS = (