Manage email users and DKIM keys for a Postfix + Dovecot + OpenDKIM setup
Find a file
2024-02-12 17:31:12 +01:00
pkg fix(config): add the option of a default provider 2024-02-12 17:31:12 +01:00
.env feat(init): First commit 2024-02-11 19:59:34 +01:00
.gitignore fix keys 2024-02-11 20:36:28 +01:00
docker-compose.yml feat(init): First commit 2024-02-11 19:59:34 +01:00
go.mod feat(init): First commit 2024-02-11 19:59:34 +01:00
go.sum feat(init): First commit 2024-02-11 19:59:34 +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 feat(init): First commit 2024-02-11 19:59:34 +01:00

mailout

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.

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

  • Postgres with a 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 and you're good