docs/production/email-gateway.md
Zulip's incoming email gateway integration makes it possible to send messages into Zulip by sending an email. It's highly recommended because it enables:
Once this integration is configured, each channel will have a special email address displayed on the channel settings page. Emails sent to that address will be delivered into the channel.
There are two ways to configure Zulip's email gateway:
[email protected]) every minute for new emails.The local delivery configuration is preferred for production because it supports nicer looking email addresses and has no cron delay. The polling option is convenient for testing/developing this feature because it doesn't require a public IP address, setting up MX records in DNS, or adjusting firewalls.
:::{note} Incoming emails are rate-limited, with the following limits:
:::
Zulip's Puppet configuration provides everything needed to run this integration; you just need to enable and configure it as follows.
The main decision you need to make is what email domain you want to
use for the gateway; for this discussion we'll use
emaildomain.example.com. The email addresses used by the gateway
will look like [email protected], so we recommend using
EXTERNAL_HOST here.
We will use hostname.example.com as the hostname of the Zulip server
(this will usually also be the same as EXTERNAL_HOST, unless you are
using an HTTP reverse proxy).
Using your DNS provider, create a DNS MX (mail exchange) record
configuring email for emaildomain.example.com to be processed by
hostname.example.com. You can check your work using this command:
$ dig +short emaildomain.example.com -t MX
1 hostname.example.com
If you have a network firewall enabled, configure it to allow incoming access to port 25 on the Zulip server from the public internet. Other mail servers will need to use it to deliver emails to Zulip.
Log in to your Zulip server; the remaining steps all happen there.
Add , zulip::local_mailserver to puppet_classes in
/etc/zulip/zulip.conf. A typical value after this change is:
puppet_classes = zulip::profile::standalone, zulip::local_mailserver
Run /home/zulip/deployments/current/scripts/zulip-puppet-apply
(and answer y) to apply your new /etc/zulip/zulip.conf
configuration to your Zulip server.
Edit /etc/zulip/settings.py, and set EMAIL_GATEWAY_PATTERN
to "%[email protected]".
Restart your Zulip server with
/home/zulip/deployments/current/scripts/restart-server.
Congratulations! The integration should be fully operational.
Create an email account dedicated to Zulip's email gateway
messages. We assume the address is of the form
[email protected]. The email provider needs to support the
standard model of delivering emails sent to
[email protected] to the [email protected] inbox.
Edit /etc/zulip/settings.py, and set EMAIL_GATEWAY_PATTERN to
"username+%[email protected]".
Set up IMAP for your email account and obtain the authentication details. (Here's how it works with Gmail)
Configure IMAP access in the appropriate Zulip settings:
/etc/zulip/settings.py
in the email gateway integration section (EMAIL_GATEWAY_LOGIN and others)./etc/zulip/zulip-secrets.conf as email_gateway_password.Test your configuration by sending emails to the target email account and then running the Zulip tool to poll that inbox:
su zulip -c '/home/zulip/deployments/current/manage.py email_mirror'
Once everything is working, install the cron job which will poll the inbox every minute for new messages using the tool you tested in the last step:
cd /home/zulip/deployments/current/
sudo cp puppet/zulip/files/cron.d/email-mirror /etc/cron.d/
Congratulations! The integration should be fully operational.