2019-07-05 17:33:48 +02:00
|
|
|
# Incoming email integration
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
* When users reply to one of Zulip's missed message email
|
|
|
|
notifications from their email client, the reply can go directly
|
|
|
|
into Zulip.
|
|
|
|
* Integrating third-party services that can send email notifications
|
|
|
|
into Zulip. See the [integration
|
|
|
|
documentation](https://zulipchat.com/integrations/doc/email) for
|
|
|
|
details.
|
|
|
|
|
2019-07-10 22:44:06 +02:00
|
|
|
Once this integration is configured, each stream will have a special
|
2019-07-05 17:33:48 +02:00
|
|
|
email address displayed on the stream settings page. Emails sent to
|
|
|
|
that address will be delivered into the stream.
|
|
|
|
|
2019-07-10 22:44:06 +02:00
|
|
|
There are two ways to configure Zulip's email gateway:
|
2019-07-05 17:33:48 +02:00
|
|
|
|
|
|
|
1. Local delivery (recommended): A postfix server runs on the Zulip
|
|
|
|
server and passes the emails directly to Zulip.
|
|
|
|
1. Polling: A cron job running on the Zulip server checks an IMAP
|
|
|
|
inbox (`username@example.com`) 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 or setting up MX
|
|
|
|
records in DNS.
|
|
|
|
|
|
|
|
## Local delivery setup
|
|
|
|
|
2019-07-11 23:21:43 +02:00
|
|
|
Zulip's puppet configuration provides everything needed to run this
|
2019-07-11 23:01:29 +02:00
|
|
|
integration; you just need to enable and configure it as follows.
|
2019-07-05 17:33:48 +02:00
|
|
|
|
2019-07-11 23:01:29 +02:00
|
|
|
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 `foo@emaildomain.example.com`, 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][reverse-proxy]).
|
|
|
|
|
|
|
|
1. 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:
|
2019-07-05 17:33:48 +02:00
|
|
|
|
|
|
|
```
|
2019-07-11 23:01:29 +02:00
|
|
|
$ dig +short emaildomain.example.com -t MX
|
|
|
|
1 hostname.example.com
|
2019-07-05 17:33:48 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
1. Login to your Zulip server; the remaining steps all happen there.
|
|
|
|
|
2019-07-11 23:01:29 +02:00
|
|
|
1. Add `, zulip::postfix_localmail` to `puppet_classes` in
|
|
|
|
`/etc/zulip/zulip.conf`. A typical value after this change is:
|
|
|
|
```
|
|
|
|
puppet_classes = zulip::voyager, zulip::postfix_localmail
|
|
|
|
```
|
|
|
|
|
|
|
|
1. If `hostname.example.com` is different from
|
|
|
|
`emaildomain.example.com`, add a section to `/etc/zulip/zulip.conf`
|
|
|
|
on your Zulip server like this:
|
2019-07-05 17:33:48 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
[postfix]
|
2019-07-11 23:01:29 +02:00
|
|
|
mailname = emaildomain.example.com
|
2019-07-05 17:33:48 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
This tells postfix to expect to receive emails at addresses ending
|
2019-07-11 23:01:29 +02:00
|
|
|
with `@emaildomain.example.com`, overriding the default of
|
2019-07-05 17:33:48 +02:00
|
|
|
`@hostname.example.com`.
|
|
|
|
|
|
|
|
1. 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.
|
|
|
|
|
|
|
|
1. Edit `/etc/zulip/settings.py`, and set `EMAIL_GATEWAY_PATTERN`
|
2019-07-11 23:01:29 +02:00
|
|
|
to `"%s@emaildomain.example.com"`.
|
2019-07-05 17:33:48 +02:00
|
|
|
|
|
|
|
1. Restart your Zulip server with
|
|
|
|
`/home/zulip/deployments/current/scripts/restart-server`.
|
|
|
|
|
|
|
|
Congratulations! The integration should be fully operational.
|
|
|
|
|
|
|
|
[reverse-proxy]: ../production/deployment.html#putting-the-zulip-application-behind-a-reverse-proxy
|
|
|
|
|
|
|
|
## Polling setup
|
|
|
|
|
2019-07-10 22:44:06 +02:00
|
|
|
1. Create an email account dedicated to Zulip's email gateway
|
2019-07-05 17:33:48 +02:00
|
|
|
messages. We assume the address is of the form
|
|
|
|
`username@example.com`. The email provider needs to support the
|
2019-07-10 22:44:06 +02:00
|
|
|
standard model of delivering emails sent to
|
2019-07-05 17:33:48 +02:00
|
|
|
`username+stuff@example.com` to the `username@example.com` inbox.
|
|
|
|
|
|
|
|
1. Edit `/etc/zulip/settings.py`, and set `EMAIL_GATEWAY_PATTERN` to
|
|
|
|
`"username+%s@example.com"`.
|
|
|
|
|
|
|
|
1. Set up IMAP for your email account and obtain the authentication details.
|
|
|
|
([Here's how it works with Gmail](https://support.google.com/mail/answer/7126229?hl=en))
|
|
|
|
|
|
|
|
1. Configure IMAP access in the appropriate Zulip settings:
|
|
|
|
* Login and server connection details in `/etc/zulip/settings.py`
|
|
|
|
in the email gateway integration section (`EMAIL_GATEWAY_LOGIN` and others).
|
|
|
|
* Password in `/etc/zulip/zulip-secrets.conf` as `email_gateway_password`.
|
|
|
|
|
|
|
|
1. Install a cron job to poll the inbox every minute for new messages:
|
|
|
|
```
|
|
|
|
cd /home/zulip/deployments/current/
|
|
|
|
sudo cp puppet/zulip/files/cron.d/email-mirror /etc/cron.d/
|
|
|
|
```
|
|
|
|
|
|
|
|
Congratulations! The integration should be fully operational.
|