Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

email testing: Store the SMTP settings in dev-secrets.

Vishnu KS7a6285ede7b4
diff --git a/docs/subsystems/email.md b/docs/subsystems/email.md
index f5a4d6cbc36..b8781e13230 100644
--- a/docs/subsystems/email.md
+++ b/docs/subsystems/email.md
@@ -59,19 +59,44 @@ custom backend, `EmailLogBackEnd`. It does the following:
* Print a friendly message on console advertising `/emails` to make
this nice and discoverable.
+### Testing in a real email client
+
You can also forward all the emails sent in the development environment
to an email id of your choice by clicking on **Forward emails to a mail
account** in `/emails` page. This feature can be used for testing how
-emails gets rendered by different email clients. Before enabling this
-you have to first configure the following SMTP settings.
-
-* The hostname `EMAIL_HOST` in `zproject/dev_settings.py`.
-* The port `EMAIL_PORT` in `zproject/dev_settings.py`.
-* The username `EMAIL_HOST_USER` in `zproject/dev_settings.py`.
-* The password `email_password` in `zproject/dev-secrets.conf`.
-
-See [this](../production/email.html#free-outgoing-email-services)
-section for instructions on obtaining SMTP details.
+emails gets rendered by different email clients.
+
+For using this feature you need to have access to the login credentials of
+an SMTP provider. The easiest way to do this would be to use Gmail
+as the SMTP provider. Go through
+[this doc](../production/email.html#using-gmail-for-outgoing-email) and
+configure Gmail to allow sending emails using it's SMTP server. You can
+ignore the warning to avoid using Gmail for sending emails since the doc
+is written for production environment.
+
+There are a bunch of other methods described
+[here](../production/email.html#free-outgoing-email-services) as well if you
+don't have a Gmail account or don't want to use it.
+
+Once you have the login credentials of the SMTP provider, set the appropriate value
+of the following keys in `zproject/dev-secrets.conf`
+
+* `email_host` - SMTP hostname.
+* `email_port` - SMTP port.
+* `email_host_user` - Username of the SMTP user
+* `email_password` - Password of the SMTP user.
+
+Here is an example of how `zproject/dev-secrets.conf` would look if you are using Gmail.
+
+```
+email_host = smtp.gmail.com
+email_port = 587
+email_host_user = [email protected]
+
+# This is different from your Gmail password if you have 2FA enabled for your Google account.
+# See the configuring Gmail to send email section above for more details
+email_password = gmail_password
+```
**Note: The base_image_uri of the images in forwarded emails would be replaced
with `https://chat.zulip.org/static/images/emails` inorder for the email clients
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py
index 4e4d0ac242e..72ffda4739d 100644
--- a/tools/linter_lib/custom_check.py
+++ b/tools/linter_lib/custom_check.py
@@ -661,7 +661,7 @@ markdown_rules = RuleList(
{'pattern': r'\[(?P<url>[^\]]+)\]\((?P=url)\)',
'description': 'Linkified Markdown URLs should use cleaner <http://example.com> syntax.'},
{'pattern': 'https://zulip.readthedocs.io/en/latest/[a-zA-Z0-9]',
- 'exclude': {'docs/overview/contributing.md', 'docs/overview/readme.md', 'docs/README.md'},
+ 'exclude': {'docs/overview/contributing.md', 'docs/overview/readme.md', 'docs/README.md', 'docs/subsystems/email.md'},
'include_only': {'docs/'},
'description': "Use relative links (../foo/bar.html) to other documents in docs/",
},
diff --git a/zproject/computed_settings.py b/zproject/computed_settings.py
index 6c91f8bdd74..f1ca16117a8 100644
--- a/zproject/computed_settings.py
+++ b/zproject/computed_settings.py
@@ -1108,6 +1108,11 @@ else:
EMAIL_TIMEOUT = 15
+if DEVELOPMENT:
+ EMAIL_HOST = get_secret('email_host', '')
+ EMAIL_PORT = int(get_secret('email_port', '25'))
+ EMAIL_HOST_USER = get_secret('email_host_user', '')
+
EMAIL_HOST_PASSWORD = get_secret('email_password')
EMAIL_GATEWAY_PASSWORD = get_secret('email_gateway_password')
AUTH_LDAP_BIND_PASSWORD = get_secret('auth_ldap_bind_password', '')