Skip to content

Commit

Permalink
Clarify e-mail settings and testing. Closes kiwitcms#1070
Browse files Browse the repository at this point in the history
  • Loading branch information
schwarzkrieger committed Apr 8, 2020
1 parent a881646 commit e3fd4f1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
43 changes: 33 additions & 10 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,46 @@ Your server/docker container clock should also match the accurate time of day!
navigation bar! All other timestamps are in the same time zone!


Using Amazon SES instead of SMTP email
--------------------------------------

E-mail settings
---------------
Kiwi TCMS supports email notifications which by default are sent over SMTP and
need to be configured via the following settings::
need to be configured via the following settings:

# standard Django settings
EMAIL_HOST = 'smtp.example.com'
EMAIL_PORT = 25
DEFAULT_FROM_EMAIL = '[email protected]'
- Common settings::

DEFAULT_FROM_EMAIL = '[email protected]'
# additional Kiwi TCMS setting
EMAIL_SUBJECT_PREFIX = '[Kiwi-TCMS] '

If you'd like to use an external email service, like Amazon SES you also need
to configure the following settings::
- SMTP specific settings::

EMAIL_HOST = 'smtp.example.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'smtp_username'
EMAIL_HOST_PASSWORD = 'smtp_password'

To enable SSL or TLS support include one of the following::

EMAIL_USE_TLS = True
EMAIL_USE_SSL = True

For more details refer to Django documentation at https://docs.djangoproject.com/en/3.0/topics/email/


Testing and debugging e-mail configuration
------------------------------------------
Sending test e-mail to one or more addresses::

docker exec -it kiwi_web /Kiwi/manage.py sendtestemail [email protected] [email protected] ...

More details at: https://docs.djangoproject.com/en/3.0/ref/django-admin/#sendtestemail


Using Amazon SES instead of SMTP email
--------------------------------------

If you'd like to use an external email service, like Amazon SES you need
to configure the following settings instead::

EMAIL_BACKEND = 'django_ses.SESBackend'
AWS_SES_ACCESS_KEY_ID = 'xxxxxxxxxxxxxxxxxxxx'
Expand Down
13 changes: 13 additions & 0 deletions tcms/core/tests/test_sendtestemail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.core.management import call_command
from django.test import TestCase, override_settings
import socket


class TestSendTestEmail(TestCase):
"""Test manage.py sendtestemail command"""

@override_settings(EMAIL_HOST='bogus.nonexistent')
def test_send_false_server(self):
"""test command with fake SMTP server"""
call_command('sendtestemail', '--admins')
self.assertRaises(socket.gaierror)
9 changes: 8 additions & 1 deletion tcms/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,17 @@
# Email settings
# 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/2.0/topics/email/#quick-example
# https://docs.djangoproject.com/en/3.0/topics/email/
DEFAULT_FROM_EMAIL = '[email protected]'
SERVER_EMAIL = DEFAULT_FROM_EMAIL
EMAIL_SUBJECT_PREFIX = '[Kiwi-TCMS] '

# SMTP specific settings
# EMAIL_HOST = 'smtp.example.com'
# EMAIL_PORT = 25
# EMAIL_HOST_USER = 'smtp_username'
# EMAIL_HOST_PASSWORD = 'smtp_password'


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ You may want to override the following settings as well
Expand Down

0 comments on commit e3fd4f1

Please sign in to comment.