Manage email users and DKIM keys for a Postfix + Dovecot + OpenDKIM setup
Find a file
Thomas Maurice 3ccd936601
All checks were successful
build / build (push) Successful in 2m17s
imp(deps): upgrade deps
2024-02-12 18:00:54 +01:00
.gitea/workflows feat(ci): updates goreleaser action to v5 2024-02-12 17:43:24 +01:00
pkg feat(provider): makes the provider API non stupid 2024-02-12 17:32:18 +01: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(init): First commit 2024-02-11 19:59:34 +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 fix(config): add the option of a default provider 2024-02-12 17:31:12 +01:00
main.go feat(init): First commit 2024-02-11 19:59:34 +01:00
README.md doc(license+readme): updates license and readme 2024-02-12 17:31:40 +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

Warning

I halfed assed that shit on an afternoon to suit my own needs, improvements will follow, or not.

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 password, username AS user FROM users WHERE username = '%n' AND domain = '%d'
user_query = SELECT maildir, 1000 AS uid, 1000 AS gid FROM users WHERE username = '%n' AND domain = '%d' AND active = '1'

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
providers:
  ovh:
    application_key: <CHANGEME>
    application_secret: <CHANGEME>
    consumer_key: <CHANGEME>
    endpoint: ovh-eu

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