zulip/zerver/lib
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
..
markdown docs: Capitalize “Markdown” consistently. 2021-04-26 09:31:08 -07:00
url_preview python: Convert deprecated Django smart_text alias to smart_str. 2021-04-15 18:01:34 -07:00
webhooks python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
__init__.py
actions.py reactions: Extract check_add_reaction from add_reaction. 2021-04-28 09:11:08 -07:00
addressee.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
alert_words.py python: Reformat with Black, except quotes. 2021-02-12 13:11:19 -08:00
attachments.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
avatar.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
avatar_hash.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
bot_config.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
bot_lib.py embedded bot: Return message id for send_message and send_reply. 2021-04-28 08:32:21 -07:00
bot_storage.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
bulk_create.py migrations: Subscription.is_user_active denormalization - step one. 2021-03-30 09:19:03 -07:00
cache.py models: Replace __id syntax with _id where possible. 2021-04-22 14:53:00 -07:00
cache_helpers.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
camo.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
ccache.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
context_managers.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
create_user.py migrations: Subscription.is_user_active denormalization - step one. 2021-03-30 09:19:03 -07:00
data_types.py python: Reformat with Black, except quotes. 2021-02-12 13:11:19 -08:00
db.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
debug.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
dev_ldap_directory.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
digest.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
display_recipient.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
domains.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
email_mirror.py emails: Rename "missed message email" to "message notification email". 2021-04-21 10:10:54 -07:00
email_mirror_helpers.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
email_notifications.py emails: Fix incorrect onboarding email going to realm owners. 2021-04-27 17:09:27 -07:00
email_validation.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
emoji.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
error_notify.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
event_schema.py event_schema: Fix translation of typing events message_type. 2021-04-27 21:35:32 -07:00
events.py client_capabilities: Add stream_typing_notifications. 2021-04-27 20:52:21 -07:00
exceptions.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
export.py docs: Add missing space to compound verbs “log in”, “set up”, etc. 2021-04-26 09:31:08 -07:00
external_accounts.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
fix_unreads.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
generate_test_data.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
github.py python: Reformat with Black, except quotes. 2021-02-12 13:11:19 -08:00
home.py emails: Add unsubscribe link infrastructure for marketing emails. 2021-04-27 21:36:09 -07:00
hotspots.py docs: Fix spelling errors caught by codespell. 2021-04-26 09:31:08 -07:00
html_diff.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
html_to_text.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
i18n.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
import_realm.py models/realm: Add a model for storing realm playground information. 2021-04-07 08:20:53 +05:30
initial_password.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
integrations.py tests: Add a test for fixtures for non-webhook integrations. 2021-04-28 08:16:51 -07:00
logging_util.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
management.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
mdiff.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
mention.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
message.py models: Replace __id syntax with _id where possible. 2021-04-22 14:53:00 -07:00
migrate.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
mobile_auth_otp.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
name_restrictions.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
narrow.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
onboarding.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
outgoing_webhook.py outgoing_webhook: Improve invalid json handling when parsing response. 2021-04-26 09:32:35 -07:00
presence.py models: Replace __id syntax with _id where possible. 2021-04-22 14:53:00 -07:00
profile.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
push_notifications.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
pysa.py
queue.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
rate_limiter.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
realm_description.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
realm_icon.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
realm_logo.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
redis_utils.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
remote_server.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
request.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
response.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
rest.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
retention.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
send_email.py emails: Fix outgoing email handling inside the dev environment. 2021-04-28 18:00:37 -07:00
server_initialization.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
sessions.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
soft_deactivation.py models: Replace __id syntax with _id where possible. 2021-04-22 14:53:00 -07:00
sqlalchemy_utils.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
statistics.py python: Reformat with Black, except quotes. 2021-02-12 13:11:19 -08:00
storage.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
stream_subscription.py models: Replace __id syntax with _id where possible. 2021-04-22 14:53:00 -07:00
stream_topic.py subs: Allow filtering by is_user_active in get_active_subscriptions. 2021-04-19 10:10:51 -07:00
streams.py streams: Move can_access_stream_user_ids into streams.py. 2021-04-19 18:30:31 -07:00
subdomains.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
test_classes.py ldap: Add advanced LDAP realm access control. 2021-04-28 09:08:13 -07:00
test_console_output.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
test_data.source.txt docs: Capitalize Markdown consistently. 2020-08-11 10:23:06 -07:00
test_fixtures.py puppeteer_tests: Reset test environment after each run. 2021-03-25 12:58:36 -07:00
test_helpers.py email: Open a single SMTP connection to send email batches. 2021-04-26 17:27:22 -07:00
test_runner.py requirements: Re-drop direct dependency on mock. 2021-04-15 21:47:33 -07:00
tex.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
thumbnail.py python: Convert deprecated Django is_safe_url. 2021-04-15 18:01:34 -07:00
timeout.py timeout: Remove unnecessary varargs support. 2021-02-15 17:05:28 -08:00
timestamp.py python: Reformat with Black, except quotes. 2021-02-12 13:11:19 -08:00
timezone.py python: Reformat with Black, except quotes. 2021-02-12 13:11:19 -08:00
topic.py message_edit: Extract update_edit_history. 2021-04-23 15:12:09 -07:00
topic_mutes.py topic_mutes: Filter deactivated streams from get_topic_mutes. 2021-03-30 12:11:35 -07:00
transfer.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
type_debug.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
types.py linkifiers: Use dictionaries for internal structures. 2021-04-05 18:16:08 -07:00
unminify.py unminify: Fix lookup if source map does not exist in disk. 2021-03-16 14:46:18 -07:00
upload.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
url_encoding.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
user_agent.py python: Reformat with Black, except quotes. 2021-02-12 13:11:19 -08:00
user_groups.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
user_mutes.py models: Replace __id syntax with _id where possible. 2021-04-22 14:53:00 -07:00
user_status.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
users.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
utils.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
validator.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
widget.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
zcommand.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00
zephyr.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00