75 lines
2.3 KiB
Markdown
75 lines
2.3 KiB
Markdown
# 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
|
|
|
|
## 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
|
|
```yaml
|
|
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
|