mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-02-21 06:29:01 +01:00
Merge pull request #4081 from luixxiul/fix
Update docs/configuring-playbook-email.md
This commit is contained in:
commit
101b55ee7a
@ -9,62 +9,57 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# Adjusting email-sending settings (optional)
|
||||
|
||||
By default, this playbook sets up an [Exim](https://www.exim.org/) email server through which all Matrix services send emails.
|
||||
By default, this playbook sets up an [Exim](https://www.exim.org/) relay SMTP mailer service (powered by [exim-relay](https://github.com/devture/exim-relay) and the [ansible-role-exim-relay](https://github.com/mother-of-all-self-hosting/ansible-role-exim-relay) Ansible role), through which all Matrix services send emails.
|
||||
|
||||
The email server would attempt to deliver emails directly to their final destination. This may or may not work, depending on your domain configuration (SPF settings, etc.)
|
||||
**With the default setting, exim-relay attempts to deliver emails directly with the address `matrix@matrix.example.com`**, as specified by the `exim_relay_sender_address` playbook variable. See below if you want to configure the playbook to relay email through another SMTP server.
|
||||
|
||||
By default, emails are sent from `matrix@matrix.example.com`, as specified by the `exim_relay_sender_address` playbook variable.
|
||||
|
||||
> [!WARNING]
|
||||
> On some cloud providers (Google Cloud, etc.), [port 25 is always blocked](https://cloud.google.com/compute/docs/tutorials/sending-mail/), so sending email directly from your server is not possible. You will need to [relay email through another SMTP server](#relaying-email-through-another-smtp-server).
|
||||
|
||||
💡 To improve deliverability, we recommend [relaying email through another SMTP server](#relaying-email-through-another-smtp-server) anyway.
|
||||
The Ansible role for exim-relay is developed and maintained by [the MASH (mother-of-all-self-hosting) project](https://github.com/mother-of-all-self-hosting/ansible-role-exim-relay). For details about configuring exim-relay, you can check them via:
|
||||
- 🌐 [the role's documentation at the MASH project](https://github.com/mother-of-all-self-hosting/ansible-role-exim-relay/blob/main/docs/configuring-exim-relay.md) online
|
||||
- 📁 `roles/galaxy/exim_relay/docs/configuring-exim-relay.md` locally, if you have [fetched the Ansible roles](installing.md#update-ansible-roles)
|
||||
|
||||
## Firewall settings
|
||||
|
||||
No matter whether you send email directly (the default) or you relay email through another host (see how below), you'll probably need to allow outgoing traffic for TCP ports 25/587 (depending on configuration).
|
||||
No matter whether you send email directly (the default) or you relay email through another host, you'll probably need to allow outgoing traffic for TCP ports 25/587 (depending on configuration).
|
||||
|
||||
Docker automatically opens these ports in the server's firewall, so you likely don't need to do anything. If you use another firewall in front of the server, you may need to adjust it.
|
||||
|
||||
## Adjusting the playbook configuration
|
||||
|
||||
### Relaying email through another SMTP server
|
||||
### Relaying email through another SMTP server (optional)
|
||||
|
||||
If you'd like to relay email through another SMTP server, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file (adapt to your needs):
|
||||
By default, exim-relay attempts to deliver emails directly. This may or may not work, depending on your domain configuration (SPF settings, etc.)
|
||||
|
||||
**On some cloud providers such as Google Cloud, [port 25 is always blocked](https://cloud.google.com/compute/docs/tutorials/sending-mail/), so sending email directly from your server is not possible.** In this case, you will need to relay email through another SMTP server.
|
||||
|
||||
For details about configuration, refer [this section](https://github.com/mother-of-all-self-hosting/ansible-role-exim-relay/blob/main/docs/configuring-exim-relay.md#relaying-email-through-another-smtp-server) on the role's document.
|
||||
|
||||
💡 To improve deliverability, we recommend relaying email through another SMTP server anyway.
|
||||
|
||||
### Disable mail service (optional)
|
||||
|
||||
For a low-power server you might probably want to disable exim-relay. To do so, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file:
|
||||
|
||||
```yaml
|
||||
exim_relay_sender_address: "another.sender@example.com"
|
||||
exim_relay_relay_use: true
|
||||
exim_relay_relay_host_name: "mail.example.com"
|
||||
exim_relay_relay_host_port: 587
|
||||
exim_relay_relay_auth: true
|
||||
exim_relay_relay_auth_username: "another.sender@example.com"
|
||||
exim_relay_relay_auth_password: "PASSWORD_FOR_THE_RELAY_HERE"
|
||||
exim_relay_enabled: false
|
||||
```
|
||||
|
||||
**Note**: only the secure submission protocol (using `STARTTLS`, usually on port `587`) is supported. **SMTPS** (encrypted SMTP, usually on port `465`) **is not supported**.
|
||||
Note that disabling exim-relay will stop email-notifications and other similar functions from working.
|
||||
|
||||
### Sending emails using Sendgrid
|
||||
See [this entry on the FAQ](faq.md#how-do-i-optimize-this-setup-for-a-low-power-server) for other possible optimizations for a low-power server.
|
||||
|
||||
An easy and free SMTP service to set up is [Sendgrid](https://sendgrid.com/). Its free tier allows for up to 100 emails per day to be sent.
|
||||
## Installing
|
||||
|
||||
To set it up, add the following configuration to your `vars.yml` file (adapt to your needs):
|
||||
After configuring the playbook, run it with [playbook tags](playbook-tags.md) as below:
|
||||
|
||||
```yaml
|
||||
exim_relay_sender_address: "example@example.org"
|
||||
exim_relay_relay_use: true
|
||||
exim_relay_relay_host_name: "smtp.sendgrid.net"
|
||||
exim_relay_relay_host_port: 587
|
||||
exim_relay_relay_auth: true
|
||||
|
||||
# This needs to be literally the string "apikey". It is always the same for Sendgrid.
|
||||
exim_relay_relay_auth_username: "apikey"
|
||||
|
||||
# You can generate the API key password at this URL: https://app.sendgrid.com/settings/api_keys
|
||||
# The password looks something like `SG.955oW1mLSfwds7i9Yd6IA5Q.q8GTaB8q9kGDzasegdG6u95fQ-6zkdwrPP8bOeuI`.
|
||||
exim_relay_relay_auth_password: "YOUR_API_KEY_PASSWORD_HERE"
|
||||
<!-- NOTE: let this conservative command run (instead of install-all) to make it clear that failure of the command means something is clearly broken. -->
|
||||
```sh
|
||||
ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start
|
||||
```
|
||||
|
||||
The shortcut commands with the [`just` program](just.md) are also available: `just install-all` or `just setup-all`
|
||||
|
||||
`just install-all` is useful for maintaining your setup quickly ([2x-5x faster](../CHANGELOG.md#2x-5x-performance-improvements-in-playbook-runtime) than `just setup-all`) when its components remain unchanged. If you adjust your `vars.yml` to remove other components, you'd need to run `just setup-all`, or these components will still remain installed. Note these shortcuts run the `ensure-matrix-users-created` tag too.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you're having trouble with email not being delivered, it may be useful to inspect the mailer logs.
|
||||
|
||||
To do so, log in to the server with SSH and run `journalctl -f -u matrix-exim-relay`.
|
||||
See [this section](https://github.com/mother-of-all-self-hosting/ansible-role-exim-relay/blob/main/docs/configuring-exim-relay.md#troubleshooting) on the role's documentation for details.
|
||||
|
Loading…
x
Reference in New Issue
Block a user