Manage email users and DKIM keys for a Postfix + Dovecot + OpenDKIM setup
Find a file
Thomas Maurice ea1c8254b4
All checks were successful
build / build (push) Successful in 43s
fix(user cmd): fix password update panic
2024-06-28 12:04:29 +02:00
.gitea/workflows feat(ci): updates goreleaser action to v5 2024-02-12 17:43:24 +01:00
pkg fix(user cmd): fix password update panic 2024-06-28 12:04:29 +02:00
.env feat(init): First commit 2024-02-11 19:59:34 +01:00
.gitignore feat(ci): Adds some CI 2024-02-12 17:32:52 +01:00
.goreleaser.yml fix(ci): remove unused code 2024-02-12 17:37:00 +01:00
docker-compose.yml feat(misc): allows user edition, templating of the home, and more 2024-02-14 18:50:35 +01:00
go.mod imp(deps): upgrade deps 2024-02-12 18:00:54 +01:00
go.sum imp(deps): upgrade deps 2024-02-12 18:00:54 +01:00
LICENSE doc(license+readme): updates license and readme 2024-02-12 17:31:40 +01:00
mailout.yml.sample feat(misc): allows user edition, templating of the home, and more 2024-02-14 18:50:35 +01:00
main.go feat(init): First commit 2024-02-11 19:59:34 +01:00
README.md fix(README): update 2024-02-16 23:39:38 +01:00

mailout

wtfpl

This is a simple binary to handle your self hosted mail notification-sending machines.

this is not intended for human users

The premise is as follow:

  • you authenticate users with dovecot
  • you sign emails with opendkim
  • you use postfix (might work in other cases but havent tried)

The plan is basically:

  • you have one table to handle your users and their passwords
  • you have one for the DKIM keys you use
  • you have a view to expose the relevant key to use for opendkim

Features

  • Create mail users

  • Deletes them

  • Update passwords

  • Create DKIM keys

  • Delete them

  • Publish them to a DNS provider (currently only OVH)

  • Unpublish them to a DNS provider (currently only OVH)

Requirements

  • A postgresql database with a properly configured user
  • Optionally an OVH account

Dovecot

For authentication, you want to change your /etc/dovecot/dovecot-sql.conf.ext to

driver = pgsql
connect = host=YOURHOST port=5432 user=YOURUSER password=APASSWORD dbname=DBNAME

password_query = SELECT concat(username, '@', domain) AS user, password FROM users WHERE username = '%n' AND domain = '%d' AND active = true
user_query = SELECT home, 1000 AS uid, 1000 AS gid FROM users WHERE username = '%n' AND domain = '%d' AND active = true

OpenDKIM

You want to change the SigningTable and KeyTable settings in opendkim.conf to

SigningTable            dsn:pgsql://USER:PASSWORD@HOST/DATABASE/table=signing_table?keycol=domain_name?datacol=id
KeyTable                dsn:pgsql://USER:PASSWORD@HOST/DATABASE/table=dkimkeys?keycol=id?datacol=domain_name,selector,private_key

Then you should be good to go, fill yourself a config file like that

postgres:
  hostname: localhost
  port: 5432
  database: vmail
  user: postgres
  password: postgres123
  sslmode: disable
defaults:
  provider: ovh
  # this is used to create the `home` field of the user.
  # in systems with virtual mail this corresponds to the physical
  # location of the vmail directory on your host
  homeTemplate: "/var/lib/vmail/{{ .Domain }}/{{ .Username }}"
providers:
  ovh:
    application_key: <CHANGEME>
    application_secret: <CHANGEME>
    consumer_key: <CHANGEME>
    endpoint: ovh-eu

pointing to your DB/OVH account and you're good