matrix-docker-ansible-deploy/docs/configuring-playbook-bot-postmoogle.md
2023-03-20 05:59:55 -07:00

4.5 KiB

Setting up Postmoogle (optional)

Note: email bridging can also happen via the email2matrix bridge supported by the playbook.

The playbook can install and configure Postmoogle for you.

It's a bot/bridge you can use to forward emails to Matrix rooms

See the project's documentation to learn what it does and why it might be useful to you.

Adjusting the playbook configuration

Add the following configuration to your inventory/host_vars/matrix.DOMAIN/vars.yml file:

matrix_bot_postmoogle_enabled: true

# Uncomment and adjust this part if you'd like to use a username different than the default
# matrix_bot_postmoogle_login: postmoogle

# Generate a strong password here. Consider generating it with `pwgen -s 64 1`
matrix_bot_postmoogle_password: PASSWORD_FOR_THE_BOT

Use Postmoogle for sending mails

You will need to add several DNS records See Configuring DNS.

To be able to get the value for !pm dkim for your DNS settings you need to have admin-rights for the bridge. If you didn't set this generally for all bridges with:

matrix_admin: "@username:{{ matrix_domain }}"

you need to set one for administering postmoogle with this item in your vars.yml:

matrix_bot_postmoogle_admins:
  - "@<username>:{{ matrix_domain }}"

If you want to use TLS (you should) and you use matrix_ssl_retrieval_method: manually-managed) you have to add to vars.yml:

### SSL
## on-host SSL dir
matrix_bot_postmoogle_ssl_path: ""

## in-container SSL paths
# matrix_bot_postmoogle_tls_cert is the SSL certificate's certificate.
# This is likely set via group_vars/matrix_servers, so you don't need to set it.
# If you do need to set it manually, note that this is an in-container path.
# To mount a certificates volumes into the container, use matrix_bot_postmoogle_ssl_path
# Example value: /ssl/live/{{ matrix_bot_postmoogle_domain }}/fullchain.pem
matrix_bot_postmoogle_tls_cert: ""

# matrix_bot_postmoogle_tls_key is the SSL certificate's key.
# This is likely set via group_vars/matrix_servers, so you don't need to set it.
# If you do need to set it manually, note that this is an in-container path.
# To mount a certificates volumes into the container, use matrix_bot_postmoogle_ssl_path
# Example value: /ssl/live/{{ matrix_bot_postmoogle_domain }}/privkey.pem
matrix_bot_postmoogle_tls_key: ""

Note: matrix_bot_postmoogle_ssl_path: defaults to what you set for matrix_ssl_config_dir_path: As seen in /group_vars/matrix_servers but it has to be set again to make postmoogle look for it outside the docker-container.

Open Ports

If you run a firewall on your server and/or it sits behind a NAT-Router, remember to open/forward the ports 25 (for non-TLS) and 587 (TLS) as set here

It's possible to change those ports in vars.yml with:

matrix_bot_postmoogle_smtp_host_bind_port: ""
matrix_bot_postmoogle_submission_host_bind_port: ""

If you want to enforce TLS on both ports add this to vars.yml:

matrix_bot_postmoogle_tls_required: true

Installing

After configuring the playbook, run the installation command again:

ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,ensure-matrix-users-created,start

Notes:

  • the ensure-matrix-users-created playbook tag makes the playbook automatically create the bot's user account

  • if you change the bot password (matrix_bot_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 to change it, and then update matrix_bot_postmoogle_password to let the bot know its new password

Usage

To use the bot, invite the @postmoogle:DOMAIN into a room you want to use as a mailbox.

Then send !pm mailbox NAME to expose this Matrix room as an inbox with the email address NAME@matrix.domain. Emails sent to that email address will be forwarded to the room.

Send !pm help to the room to see the bot's help menu for additional commands.

You can also refer to the upstream documentation.