zulip/zproject
pletinckxc 184df7e656 emails: Fix outgoing email handling inside the dev environment.
Commit 9afde790c6 introduced a bug
concerning outgoing emails inside the development environment. These
emails are not supposed to use a real connection with a mail
server as the send_messages function is overwritten inside the
EmailLogBackEnd class.

The bug was happening inside the initialize_connection function that
was introduced in the above-mentioned commit. This function is used
to refresh the connection with an SMTP server that would have closed
it. As the socket used to communicate with the server is not
initialized inside the development environment this function was
wrongly trying to send no-op commands.

The fix just checks that the connection argument of the function is
an EmailLogBackEnd object before trying the no-op command.
Additionally as it is sometimes useful to be able to send outgoing
emails inside the development environment the get_forward_address
function is used to check if a real connection exists between Zulip
and the server. If it is the case, as EmailLogBackEnd is a subclass
of smtp.EmailBackend, the connection will be nicely refreshed.

This commit was tested manually by checking that the console prints
correctly that an email is sent to the user when it signs in inside
the development environment. It was also tested when a mail provider
is specified and the mails were correctly received.
2021-04-28 18:00:37 -07:00
..
jinja2 i18n: Pass language name with every response. 2021-04-24 13:00:27 -07:00
__init__.py
backends.py ldap: Add advanced LDAP realm access control. 2021-04-28 09:08:13 -07:00
computed_settings.py requirements: Remove django-webpack-loader. 2021-04-06 09:31:35 -07:00
config.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
configured_settings.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
default_settings.py ldap: Add advanced LDAP realm access control. 2021-04-28 09:08:13 -07:00
dev_settings.py docs: Add missing space to compound verbs “log in”, “set up”, etc. 2021-04-26 09:31:08 -07:00
dev_urls.py refactor: Move dev related code from `urls.py` to `dev_urls.py`. 2021-04-23 15:11:44 -07:00
email_backends.py emails: Fix outgoing email handling inside the dev environment. 2021-04-28 18:00:37 -07:00
legacy_urls.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
prod_settings_template.py ldap: Add advanced LDAP realm access control. 2021-04-28 09:08:13 -07:00
sentry.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
settings.py python: Add noqa comments for the specific star imports we allow. 2020-06-11 15:36:43 -07:00
terms.md.template docs: Capitalize Markdown consistently. 2020-08-11 10:23:06 -07:00
test_extra_settings.py requirements: Remove django-webpack-loader. 2021-04-06 09:31:35 -07:00
test_settings.py test_settings: Use TEST_EXTERNAL_HOST to override ‘testserver’ default. 2020-12-17 13:07:59 -08:00
urls.py refactor: Move dev related code from `urls.py` to `dev_urls.py`. 2021-04-23 15:11:44 -07:00
wsgi.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00