diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index f3f9904592..b386cd2d5f 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -25,17 +25,18 @@ Using Amazon SES instead of SMTP email Kiwi TCMS supports email notifications which by default are sent over SMTP and need to be configured via the following settings:: - EMAIL_HOST = '' + # standard Django settings + EMAIL_HOST = 'smtp.example.com' EMAIL_PORT = 25 - EMAIL_FROM = 'kiwi@example.com' + DEFAULT_FROM_EMAIL = 'kiwi@example.com' + + # additional Kiwi TCMS setting EMAIL_SUBJECT_PREFIX = '[Kiwi-TCMS] ' -If you'd like to use an external email service, like Amazon SES you have to -configure the following settings instead:: +If you'd like to use an external email service, like Amazon SES you also need to +configure the following settings:: + - EMAIL_HOST = 'example.com' - EMAIL_FROM = 'kiwi@example.com' - DEFAULT_FROM_EMAIL = EMAIL_FROM EMAIL_BACKEND = 'django_ses.SESBackend' AWS_SES_ACCESS_KEY_ID = 'xxxxxxxxxxxxxxxxxxxx' AWS_SES_SECRET_ACCESS_KEY = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY' diff --git a/tcms/core/contrib/auth/tests.py b/tcms/core/contrib/auth/tests.py index f2e4c9a0d4..294bc574b0 100644 --- a/tcms/core/contrib/auth/tests.py +++ b/tcms/core/contrib/auth/tests.py @@ -132,7 +132,7 @@ def assert_user_registration(self, username, sha1): return response @patch('tcms.core.utils.mailto.send_mail') - @patch('tcms.core.contrib.auth.views.settings.EMAIL_HOST', new='smtp.example.com') + @patch('tcms.core.contrib.auth.views.settings.DEFAULT_FROM_EMAIL', new='kiwi@example.com') def test_register_user_by_email_confirmation(self, send_mail): response = self.assert_user_registration('new-tester') @@ -151,9 +151,9 @@ def test_register_user_by_email_confirmation(self, send_mail): %s """ % confirm_url, - settings.EMAIL_FROM, ['new-tester@example.com'], fail_silently=False) + settings.DEFAULT_FROM_EMAIL, ['new-tester@example.com'], fail_silently=False) - @patch('tcms.core.contrib.auth.views.settings.EMAIL_HOST', new='') + @patch('tcms.core.contrib.auth.views.settings.DEFAULT_FROM_EMAIL', new='') @patch('tcms.core.contrib.auth.views.settings.ADMINS', new=[('admin1', 'admin1@example.com'), ('admin2', 'admin2@example.com')]) diff --git a/tcms/core/contrib/auth/views.py b/tcms/core/contrib/auth/views.py index be0ac9477c..8c68d64c5c 100644 --- a/tcms/core/contrib/auth/views.py +++ b/tcms/core/contrib/auth/views.py @@ -37,8 +37,8 @@ def register(request, template_name='registration/registration_form.html'): form.save() ak = form.set_active_key() - # Send email to user if mail server is available. - if form.cleaned_data['email'] and settings.EMAIL_HOST: + # Send email to user if email is configured. + if form.cleaned_data['email'] and settings.DEFAULT_FROM_EMAIL: form.send_confirm_mail(request=request, active_key=ak) msg = 'Your account has been created, please check your ' \ diff --git a/tcms/core/utils/mailto.py b/tcms/core/utils/mailto.py index e7888e97b5..65973594ce 100644 --- a/tcms/core/utils/mailto.py +++ b/tcms/core/utils/mailto.py @@ -7,7 +7,7 @@ def mailto(template_name, subject, recipients=None, - context=None, sender=settings.EMAIL_FROM, + context=None, sender=settings.DEFAULT_FROM_EMAIL, cc=None): # make a list with recipients and filter out duplicates if isinstance(recipients, list): diff --git a/tcms/settings/common.py b/tcms/settings/common.py index ffa539887e..c3e8bf92ef 100644 --- a/tcms/settings/common.py +++ b/tcms/settings/common.py @@ -39,10 +39,10 @@ # Email settings -# EMAIL_HOST must be defined if you want Kiwi TCMS to send emails -EMAIL_HOST = '' -EMAIL_PORT = 25 -EMAIL_FROM = 'kiwi@example.com' +# DEFAULT_FROM_EMAIL must be defined if you want Kiwi TCMS to send emails. +# You also need to configure the email backend. For more information see: +# https://docs.djangoproject.com/en/1.11/topics/email/#quick-example +DEFAULT_FROM_EMAIL = 'kiwi@example.com' EMAIL_SUBJECT_PREFIX = '[Kiwi-TCMS] '