2024-10-23 02:36:24 +09:00
# Setting up Postmoogle email bridging (optional)
2022-08-22 20:10:35 +03:00
**Note**: email bridging can also happen via the [email2matrix ](configuring-playbook-email2matrix.md ) bridge supported by the playbook.
2024-09-07 02:43:00 +03:00
The playbook can install and configure [Postmoogle ](https://github.com/etkecc/postmoogle ) for you.
2022-08-22 20:10:35 +03:00
2024-10-28 23:27:42 +09:00
Postmoogle is a bridge you can use to have its bot user forward emails to Matrix rooms. It runs an SMTP email server and allows you to assign mailbox addresses to the rooms.
2022-08-22 20:10:35 +03:00
2024-12-17 18:23:37 +09:00
See the project's [documentation ](https://github.com/etkecc/postmoogle/blob/master/README.md ) to learn what it does and why it might be useful to you.
2022-08-22 20:10:35 +03:00
2023-05-29 04:03:31 -06:00
## Prerequisites
2022-08-22 20:10:35 +03:00
2023-05-30 09:09:24 +03:00
Open the following ports on your server to be able to receive incoming emails:
2023-05-29 04:03:31 -06:00
- `25/tcp` : SMTP
2023-05-30 09:09:24 +03:00
- `587/tcp` : Submission (TLS-encrypted SMTP)
2023-05-29 04:03:31 -06:00
2023-05-30 09:09:24 +03:00
If you don't open these ports, you will still be able to send emails, but not receive any.
2023-05-29 04:03:31 -06:00
2024-10-31 17:33:46 +09:00
These port numbers are configurable via the `matrix_postmoogle_smtp_host_bind_port` and `matrix_postmoogle_submission_host_bind_port` variables, but other email servers will try to deliver on these default (standard) ports, so changing them is of little use.
2023-05-29 04:03:31 -06:00
2025-01-15 16:22:00 +09:00
## Adjusting DNS records
To make Postmoogle enable its email sending features, you need to configure MX and TXT (SPF, DMARC, and DKIM) records. See the table below for values which need to be specified.
| Type | Host | Priority | Weight | Port | Target |
|------|--------------------------------|----------|--------|------|------------------------------------|
| MX | `matrix` | 10 | 0 | - | `matrix.example.com` |
| TXT | `matrix` | - | - | - | `v=spf1 ip4:matrix-server-IP -all` |
| TXT | `_dmarc.matrix` | - | - | - | `v=DMARC1; p=quarantine;` |
| TXT | `postmoogle._domainkey.matrix` | - | - | - | get it from `!pm dkim` |
**Note**: the DKIM record can be retrieved after configuring and installing the bridge's bot.
2024-10-22 20:29:49 +09:00
## Adjusting the playbook configuration
2022-08-22 20:10:35 +03:00
2024-10-17 22:17:56 +09:00
Add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file:
2022-08-22 20:10:35 +03:00
```yaml
2024-10-31 17:33:46 +09:00
matrix_postmoogle_enabled: true
2022-08-22 20:10:35 +03:00
2022-11-01 16:22:58 +02:00
# Uncomment and adjust this part if you'd like to use a username different than the default
2024-10-31 17:33:46 +09:00
# matrix_postmoogle_login: postmoogle
2022-11-01 16:22:58 +02:00
2024-12-22 14:59:40 +09:00
# Generate a strong password for the bot. You can create one with a command like `pwgen -s 64 1`.
2024-10-31 17:33:46 +09:00
matrix_postmoogle_password: PASSWORD_FOR_THE_BOT
2022-08-22 20:10:35 +03:00
2023-05-30 09:09:24 +03:00
# Uncomment to add one or more admins to this bridge:
#
2024-10-31 17:33:46 +09:00
# matrix_postmoogle_admins:
2024-10-10 22:17:04 +09:00
# - '@yourAdminAccount:{{ matrix_domain }}'
2023-05-30 09:09:24 +03:00
#
2025-01-11 23:50:51 +09:00
# … unless you've made yourself an admin of all bots/bridges like this:
2023-05-30 09:09:24 +03:00
#
2024-10-10 22:17:04 +09:00
# matrix_admin: '@yourAdminAccount:{{ matrix_domain }}'
2023-05-29 04:03:31 -06:00
```
2022-08-22 20:10:35 +03:00
## Installing
2024-12-01 16:42:30 +09:00
After configuring the playbook, run it with [playbook tags ](playbook-tags.md ) as below:
2022-08-22 20:10:35 +03:00
2024-12-01 16:42:30 +09:00
<!-- NOTE: let this conservative command run (instead of install - all) to make it clear that failure of the command means something is clearly broken. -->
2022-11-01 16:22:58 +02:00
```sh
ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,ensure-matrix-users-created,start
2022-08-22 20:10:35 +03:00
```
2022-11-01 16:22:58 +02:00
**Notes**:
2024-12-01 16:42:30 +09:00
- The `ensure-matrix-users-created` playbook tag makes the playbook automatically create a user account of the bridge's bot.
2022-11-01 16:22:58 +02:00
Edit installing instructions (#3844)
* Replace "just run-tags install-all/setup-all,start" with "just install-all/setup-all"
Thanks to the tip by Slavi that the overhead of ensure-matrix-users-created is negligible.
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
* Edit installing instructions
- Move the anchor links to docs/just.md
- Add note about running "ensure-matrix-users-created" tags, if ansible-playbook's tags not "setup-all,ensure-matrix-users-created,start", ie. either "setup-all,start", "setup-email2matrix,start", "setup-aux-files,setup-corporal,start", or "setup-matrix-user-verification-service,start"
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
* Update descriptions about installation
- Introduce the most conservative and stable raw ansible-playbook command.
- Introduce the just commands on installing.md and maintenance-upgrading-services.md, not on quick-start.md, since it is too early for quick start guide readers who are just starting to climb learning curve to use the shortcuts.
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
* Update docs/configuring-playbook-etherpad.md: remove the note about ensure-matrix-users-created
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
---------
Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
Co-authored-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
2024-12-02 00:04:54 +09:00
- The shortcut commands with the [`just` program ](just.md ) are also available: `just install-all` or `just setup-all`
2022-08-22 20:10:35 +03:00
2024-12-02 14:29:44 +09:00
`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.
2024-12-01 16:42:30 +09:00
- If you change the bridge's bot password (`matrix_postmoogle_password` in your `vars.yml` file) subsequently, the bot user's credentials on the homeserver won't be updated automatically. If you'd like to change the bot user's password, use a tool like [synapse-admin ](configuring-playbook-synapse-admin.md ) to change it, and then update `matrix_postmoogle_password` to let the bot know its new password.
2022-08-22 20:10:35 +03:00
## Usage
2024-10-28 23:27:42 +09:00
To use the bridge, invite the `@postmoogle:example.com` bot user into a room you want to use as a mailbox.
2022-08-23 10:31:11 +00:00
2024-10-18 12:15:53 +09:00
Then send `!pm mailbox NAME` to expose this Matrix room as an inbox with the email address `NAME@matrix.example.com` . Emails sent to that email address will be forwarded to the room.
2022-08-22 20:10:35 +03:00
2024-12-19 03:24:04 +09:00
Send `!pm help` to the bot in the room to see the available commands.
2022-08-22 20:10:35 +03:00
2024-09-07 02:43:00 +03:00
You can also refer to the upstream [documentation ](https://github.com/etkecc/postmoogle ).
2023-05-29 04:03:31 -06:00
### Debug/Logs
2023-05-30 09:09:24 +03:00
2024-10-31 17:33:46 +09:00
As with all other services, you can find their logs in [systemd-journald ](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html ) by running something like `journalctl -fu matrix-postmoogle`
2023-05-30 09:09:24 +03:00
2024-09-07 01:05:34 +03:00
The default logging level for this bridge is `INFO` , but you can increase it to `DEBUG` with the following additional configuration:
2023-05-29 04:03:31 -06:00
```yaml
2024-10-31 17:33:46 +09:00
matrix_postmoogle_loglevel: 'DEBUG'
2023-05-29 04:03:31 -06:00
```