mailcow-dockerized-docs/docs/firststeps-dmarc_reporting.md

102 Zeilen
3,9 KiB
Markdown

2020-09-24 20:49:33 +02:00
DMARC Reporting done via Rspamd DMARC Module.
2021-08-28 15:26:19 +02:00
Rspamd documentation can be found here: https://rspamd.com/doc/modules/dmarc.html
2020-09-24 20:49:33 +02:00
**Important:**
2021-08-28 18:23:49 +02:00
1. Before you use the examples below, change `example.com`, `mail.example.com` and `Example` to reflect your setup
2. DMARC reporting requires additional attention, especially over the first few days
3. All receiving domains hosted on mailcow send from one reporting domain. Recommended to use parent domain of your `MAILCOW_HOSTNAME`, for example:
- if your `MAILCOW_HOSTNAME=mail.example.com` then change your reporting config to match `domain = "example.com";`
- set `email` from the same domain also, `email = "noreply-dmarc@example.com";`
2021-08-28 15:26:19 +02:00
4. This optional, but recommended step: create `noreply-dmarc` email user in mailcow to handle bounces.
2020-09-24 20:49:33 +02:00
- Go to mailcow admin UI → Configuration → Mail Setup → Mailboxes → Add mailbox → Create mailbox `noreply-dmarc`, please choose correct domain
2021-08-28 18:23:49 +02:00
- In case you want silently discard bounces: login in SOGo from this account and go to Preferences → Mail → Filters → Create Filter → Add action → Provide name, enter `noreply` and add action: Discard the message and save filter
- In case you plan to resend a copy of reports to yourself, you need to add a condition to previous filter example `From is not noreply-dmarc@example.com`
2020-09-24 20:49:33 +02:00
2021-08-28 15:26:19 +02:00
## Enable DMARC Reporting
2021-08-28 18:23:49 +02:00
1. Create or edit file in `data/conf/rspamd/local.d/dmarc.conf` and set contents to:
2020-09-24 20:49:33 +02:00
```
2021-08-28 15:26:19 +02:00
reporting {
enabled = true;
email = 'noreply-dmarc@example.com';
domain = 'example.com';
org_name = 'Example';
helo = 'rspamd';
smtp = 'postfix';
2020-09-24 20:49:33 +02:00
smtp_port = 25;
2021-08-28 15:26:19 +02:00
from_name = 'Example DMARC Report';
msgid_from = 'rspamd.mail.example.com';
max_entries = 2k;
keys_expire = 2d;
2020-09-24 20:49:33 +02:00
}
```
2021-08-28 15:26:19 +02:00
2. Create `docker-compose.override.yml` or merge with your existing one:
```
version: '2.1'
2020-09-24 20:49:33 +02:00
2021-08-28 15:26:19 +02:00
services:
rspamd-mailcow:
environment:
- MASTER=${MASTER:-y}
labels:
ofelia.enabled: "true"
ofelia.job-exec.rspamd_dmarc_reporting.schedule: "@every 24h"
ofelia.job-exec.rspamd_dmarc_reporting.command: "/bin/bash -c \"[[ $${MASTER} == y ]] && /usr/bin/rspamadm dmarc_report > /var/lib/rspamd/dmarc_reports_last_log 2>&1 || exit 0\""
ofelia-mailcow:
depends_on:
- rspamd-mailcow
```
3. Run `docker-compose up -d`
2020-09-24 20:49:33 +02:00
## Send a copy reports to yourself
2021-08-28 18:23:49 +02:00
To receive a hidden copy of reports generated by Rspamd you can set a `bcc_addrs` list in `reporting` section.
2021-08-28 15:26:19 +02:00
2021-08-28 18:23:49 +02:00
```
reporting {
enabled = true;
email = 'noreply-dmarc@example.com';
bcc_addrs = ["noreply-dmarc@example.com","parsedmarc@example.com"];
...
```
Rspamd will load changes in real time, no need to restart it.
2021-08-28 15:26:19 +02:00
2020-09-24 20:49:33 +02:00
This useful in case:
2021-08-28 18:23:49 +02:00
- you want to check that your DMARC Reports send correctly, check that they signed by DKIM, etc.
- you want to analyze own reports to get statics data, for example use with ParseDMARC or other analytic system
2020-09-24 20:49:33 +02:00
2021-08-28 15:26:19 +02:00
## Troubleshooting
2021-08-28 18:23:49 +02:00
Check when the report schedule last ran
```
docker-compose exec rspamd-mailcow date -r /var/lib/rspamd/dmarc_reports_last_log
```
See last report output
```
docker-compose exec rspamd-mailcow cat /var/lib/rspamd/dmarc_reports_last_log
```
Manually Trigger DMARC report
```
docker-compose exec rspamd-mailcow rspamadm dmarc_report
```
Validate that Rspamd has recorded data in Redis
```
docker-compose exec redis-mailcow redis-cli KEYS 'dmarc;*'
docker-compose exec redis-mailcow redis-cli HGETALL "dmarc;example.com;20211231"
```
2020-09-26 11:23:14 +02:00
2021-08-28 15:26:19 +02:00
## Change DMARC Reporting Frequency
In the example above reports are send once a 24 hours. To change this behaviour:
1. Adjust `ofelia.job-exec.rspamd_dmarc_reporting.schedule: "@every 24h"` to desired value in `docker-compose.override.yml`
2. Run `docker-compose up -d`
3. Run `docker-compose restart ofelia-mailcow`
2020-09-26 11:23:14 +02:00
2021-08-28 15:26:19 +02:00
## Disable DMARC Reporting
To disable reporting:
1. Set `enabled` to `false` in `data/conf/rspamd/local.d/dmarc.conf`
2. Revert changes done to `docker-compose.override.yml`
3. Run `docker-compose up -d`