102 lines
2.5 KiB
Markdown
102 lines
2.5 KiB
Markdown
# DOCKER MAIL SERVER (DMS)
|
|
|
|
Héberger sa boîte mail sur son serveur grâce à [Docker Mail Server](https://github.com/docker-mailserver/docker-mailserver)
|
|
|
|
## PRE REQUIS :paperclip:
|
|
|
|
- Docker + compose plugin
|
|
- Certbot
|
|
- Nom de domaine (ici exemple.com)
|
|
- Les ports 25, 143, 465, 587 et 993 ouverts
|
|
- Le port 25 ouvert en traffic sortant (Voir avec son FAI)
|
|
|
|
:warning: **Les FAIs ferme le port 25 sortant sur les boxs**
|
|
|
|
## CONFIGURER :wrench:
|
|
|
|
#### CREATION DES DNS RECORDS
|
|
|
|
- Créer les DNS suivant:
|
|
1. `A` record:
|
|
```
|
|
# mail.exemple.com point sur <IP_SERVER>
|
|
mail 10800 IN A <IP_SERVER>
|
|
```
|
|
2. `MX` record:
|
|
```
|
|
# ne pas oublier le point à la fin !!!
|
|
@ 10800 IN MX 10 mail.exemple.com.
|
|
```
|
|
3. `TXT` record (ancien SPF deprécié):
|
|
```
|
|
@ 10800 IN TXT "v=spf1 ip4:<IP_SERVER> ~all"
|
|
```
|
|
4. `TXT` record (DMARC)
|
|
```
|
|
_dmarc 10800 IN TXT "v=DMARC1; p=quarantine; sp=reject; rua=mailto:reports@exemple.com; ruf=mailto:forensics@xemple.com; fo=1"
|
|
```
|
|
5. `CNAME` record (autodiscover conf du server)
|
|
```
|
|
autodiscover 10800 IN CNAME mail.exemple.com
|
|
```
|
|
6. `TXT` record for DKIM (pour mail.example.com après création de clefs DKIM):
|
|
```
|
|
mail._domainkey 10800 IN TXT "v=DKIM1; h=sha256; k=rsa; p=<DKIM_KEYS>"
|
|
```
|
|
#### ENVS :mag:
|
|
|
|
- mailserver.env:
|
|
```env
|
|
MAIL_DNS=mail.exemple.com
|
|
POSTMASTER_ADDRESS=postmaster@exemple.com
|
|
```
|
|
|
|
#### CREATION DES CERTIFICATS SSL ::page_with_curl:
|
|
|
|
- Création des certifs via certbot:
|
|
```bash
|
|
sudo certbot certonly -d mail.exemple.com
|
|
```
|
|
|
|
- Copie des certificats pour DMS:
|
|
```bash
|
|
mkdir -p docker-data/certbot/certs/
|
|
sudo cp -r /etc/letsencrypt/live/exemple.com/ docker-data/certbot/certs/
|
|
```
|
|
|
|
#### CREATION BOITE MAIL + CLEFS DKIM :email: :key:
|
|
|
|
- Lancer la stack:
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
|
|
- Créer une adresse mail:
|
|
```bash
|
|
docker exec -it <CONTAINER NAME> setup email add user@exemple.com <PASSWORD>
|
|
```
|
|
|
|
- Créer un alias:
|
|
```bash
|
|
docker exec -ti <CONTAINER NAME> setup alias add postmaster@exemple.com user@exemple.com
|
|
```
|
|
|
|
- Créer les clefs `DKIM`:
|
|
```bash
|
|
docker exec -it <CONTAINER NAME> setup config dkim keysize 1024
|
|
```
|
|
|
|
- Reporter les datas entre () au niveau de `p=""` dans un `TXT` record (**voir étape 6 de la création des DNS records**)
|
|
|
|
Relancer la stack pour valider l'usage des clefs DKIM:
|
|
```bash
|
|
docker compose down && docker compose up -d
|
|
```
|
|
|
|
## DOCUMENTATION :books:
|
|
|
|
- [DMS](https://docker-mailserver.github.io/docker-mailserver/latest/usage/)
|
|
|
|
## TO DO :bookmark_tabs:
|
|
|
|
- [ ] Automate certbot renew |