This Ansible role installs and configures OpenSMTPD as a mail relay for servers, and optionally configures an SMTP‑to‑Matrix integration for monitoring.
It is designed for reliable, repeatable deployments in production environments.
The Ansible Role is written and actively maintained by Blunix GmbH. It is used in the Blunix Linux Managed Hosting Stack. Its usage is documented at our Linux Managed Hosting Documentation.
- Installs OpenSMTPD and required tooling.
- Manages
/etc/smtpd.confand table files under/etc/smtpd/tables/. - Configures mailname via
/etc/mailname. - Installs and configures an SMTP‑to‑Matrix bridge using Python packages and a systemd service.
- Sends test mails and checks the OpenSMTPD queue.
- Ansible: >= 2.20.0
- Managed operating systems:
- Debian trixie
The full example is split under example/:
example/inventory/group_vars/mailrelays.yml— mailrelay settings, SMTP relays, Matrix bridge, and test recipient.example/play.yml— mailrelay play using the role.
The role itself ships templates under roles/role-mailrelay-opensmtpd/templates/.
In most setups you will not override these, but you must provide values for all
referenced variables as shown above.
Templates used:
/etc/smtpd.conffromtemplates/etc/smtpd.conf.j2/etc/smtpd/tables/relay_secretsfromtemplates/etc/smtpd/tables/relay_secrets.j2/etc/smtpd/tables/monitoring_fromfromtemplates/etc/smtpd/tables/monitoring_from.j2/etc/smtpd/tables/monitoring_recipientsfromtemplates/etc/smtpd/tables/monitoring_recipients.j2/etc/mailnamefromtemplates/etc/mailname.j2/usr/local/bin/smtp-to-matrix.pyfromtemplates/usr/local/bin/smtp-to-matrix.py/etc/smtp-to-matrix/config.ymlfromtemplates/etc/smtp-to-matrix/config.yml.j2/etc/systemd/system/smtp-to-matrix.servicefromtemplates/etc/systemd/system/smtp-to-matrix.service.j2
You generally do not need to copy these templates; just ensure the variables they
use are defined in your group_vars / host_vars (especially the mailrelay_*
and monitoring_* variables shown in the example).
Blunix GmbH Berlin
root@Linux:~# Support | Consulting | Hosting | Training
Blunix GmbH provides 24/7/365 Linux emergency support and consulting, Service Level Agreements for Debian Linux managed hosting using Ansible Configuration Management as well as Linux trainings and workshops.
Learn more at https://www.blunix.com.
Click here to see our Contact Information.
For bug reports and feature requests, please open an issue in this repository’s GitHub issue tracker.
Apache-2.0
Please refer to the LICENSE file in the root of this repository.
The directory test/ contains an example play.yml as well as inventory/group_vars/, if applicable to the role. the script example/run-tests.sh creates a IONOS cloud instance with terraform, uses the example inventory and playbook to run the role and then run pytest tests located in example/tests/. Destroy the terraform using ./run-tests.sh -d.