Where is the DKIM selector configured? #4572
-
|
Given that the s=selectror value is critical for DKIM to work and you must create TXT DNS entries with that selector, I find it baffling that I cannot find an answer to that question in the wiki or online after 50mn of research. Previously I was using mailu and the selector was What sets this value and how do we change it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
replying to my own comment, I search by keyword in a bunch of files and found out: This example file comes from https://docker-mailserver.github.io/docker-mailserver/latest/config/best-practices/dkim_dmarc_spf/#rspamd and I am ashamed to admit I used it as is, and even tho I modified it thinking I understood, but nope I missed the critical part. how do I modify the page? hoe that helps anyone |
Beta Was this translation helpful? Give feedback.
-
It should default to You can set this to a custom selector instead, so that you could re-use the
So all you would need to do is run this to generate with a custom selector setup config dkim selector dkimBut this would be generating config at This command works the same for both Rspamd and OpenDKIM (verified at least for basic single mail domain use).
I didn't quite follow what you're referring to. I don't see any
What improvement do you want to add? You can click this icon at the top of each docs page to be taken to an edit screen: That will then let you send your changes as a Pull Request to our project. Our docs are written in Markdown format (with some extra syntax understood by the docs generator), so updating the docs is fairly easy :) ReproductionQuick example if it helps: name: example
services:
# We'll send mail from this DMS instance, and it'll use DKIM keys to sign outbound mail:
dms-sender:
image: ghcr.io/docker-mailserver/docker-mailserver:${DMS_RELEASE:-15.1.0}
hostname: mail.example.test
environment:
# If using Rspamd you'd want these two ENV changes:
#ENABLE_RSPAMD: 1
#ENABLE_OPENDKIM: 0
# NOTE: These ENV below are just to simplify the reproduction and aren't relevant to DKIM setup:
ENABLE_AMAVIS: 0
ENABLE_UPDATE_CHECK: 0
# Instead of `volumes` to provide these config files, I'm using the Docker Compose `configs` feature
# so it's all embedded into the single `compose.yaml`:
configs:
- source: dms-accounts
target: /tmp/docker-mailserver/postfix-accounts.cf
# I will need to persist DKIM config generated across a container restart however,
# So I've created a volume for this specifically (normally it'd be included by your standard DMS config mount):
volumes:
- ./opendkim/:/tmp/docker-mailserver/opendkim/
# Or if using Rspamd instead:
#- ./rspamd/:/tmp/docker-mailserver/rspamd/
# DMS (Postfix) will run security checks to verify the sender/recipient domains,
# Add an alias to the container here to leverage Dockers internal DNS, only since
# this reproduction example doesn't have proper DNS records setup:
networks:
default:
aliases:
- example.test
# Mail will arrive to the recipient address of this DMS instance:
dms-receiver:
image: ghcr.io/docker-mailserver/docker-mailserver:${DMS_RELEASE:-15.1.0}
hostname: mail.remote.test
environment:
ENABLE_AMAVIS: 0
ENABLE_UPDATE_CHECK: 0
networks:
default:
aliases:
- remote.test
configs:
- source: dms-accounts-remote
target: /tmp/docker-mailserver/postfix-accounts.cf
# The Docker Compose `configs` feature inlines file content into `compose.yaml`
# NOTE: `$` will be inferred as an ENV on the host to replace with a value if found,
# `$$` is required as an escape to opt-out of that feature when an actual `$` is expected in the file content.
configs:
dms-accounts:
content: |
[email protected]|{SHA512-CRYPT}$$6$$sbgFRCmQ.KWS5ryb$$EsWrlYosiadgdUOxCBHY0DQ3qFbeudDhNMqHs6jZt.8gmxUwiLVy738knqkHD4zj4amkb296HFqQ3yDq4UXt8.
dms-accounts-remote:
content: |
[email protected]|{SHA512-CRYPT}$$6$$sbgFRCmQ.KWS5ryb$$EsWrlYosiadgdUOxCBHY0DQ3qFbeudDhNMqHs6jZt.8gmxUwiLVy738knqkHD4zj4amkb296HFqQ3yDq4UXt8.# Generate the DKIM keys for our managed mail domains (example.test), with default `mail` selector:
# NOTE: This won't work for Rspamd, you'll need to instead bring the container up first and then run the command via `docker compose exec dms-sender` after DMS has completed initial setup
$ docker compose run --rm dms-sender setup config dkim
2025-09-22 01:28:56+00:00 INFO open-dkim: Creating DKIM private key '/tmp/docker-mailserver/opendkim/keys/example.test/mail.private'
# Start both DMS container instances (sender + receiver):
$ docker compose up -d --force-recreate
# Now we'll send a test mail from the sender container to the receiver container, this will be signed by DKIM:
$ docker compose exec dms-sender swaks --silent \
--server localhost --port 587 \
--auth PLAIN --auth-user [email protected] --auth-password secret \
--from [email protected] --to [email protected]
# Let's double check that the receiver DMS container got that mail (_which is using OpenDKIM default to verify_):
# (The DKIM selector can be seen as `mail` and that the DNS check failed since proper DNS isn't setup)
$ docker compose logs dms-receiver | grep dkim
dms-receiver-1 | 2025-09-22T01:17:09.011443+00:00 mail opendkim[565]: OpenDKIM Filter v2.11.0 starting (args: -f)
dms-receiver-1 | 2025-09-22T01:17:32.941701+00:00 mail opendkim[565]: DA50A240A44: example-dms-sender-1.my-network [172.16.13.4] not internal
dms-receiver-1 | 2025-09-22T01:17:32.941715+00:00 mail opendkim[565]: DA50A240A44: not authenticated
dms-receiver-1 | 2025-09-22T01:17:32.949301+00:00 mail opendkim[565]: DA50A240A44: key retrieval failed (s=mail, d=example.test): 'mail._domainkey.example.test' record not foundThe mail was delivered though, and we can see it's contents with DKIM verification result marked as failed: $ docker compose exec dms-receiver bash -c 'cat /var/mail/remote.test/jane.doe/new/*'
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from mail.remote.test
by mail.remote.test with LMTP
id VhTnEyWn0GjfAwAA88HVfQ
(envelope-from <[email protected]>)
for <[email protected]>; Mon, 22 Sep 2025 01:32:21 +0000
Authentication-Results: mail.remote.test; dmarc=none (p=none dis=none) header.from=example.test
Authentication-Results: mail.remote.test;
dkim=fail reason="key not found in DNS" header.d=example.test [email protected] header.a=rsa-sha256 header.s=mail header.b=lAGvhLrw;
dkim-atps=neutral
Received-SPF: None (mailfrom) identity=mailfrom; client-ip=172.16.13.4; helo=mail.example.test; [email protected]; receiver=remote.test
Received: from mail.example.test (example-dms-sender-1.my-network [172.16.13.4])
by mail.remote.test (Postfix) with ESMTP id 1A5E2240A8F
for <[email protected]>; Mon, 22 Sep 2025 01:32:20 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=example.test; s=mail;
t=1758504734; bh=ecGWgWCJeWxJFeM0urOVWP+KOlqqvsQYKOpYUP8nk7I=;
h=To:From:Subject;
b=lAGvhLrw52HCOmUYI8giiB2nPgP23dXbu1oLDp9Lts1wiR6stWcotPkkZiM5NPAfV
Nmuxkv+OE9wYXkLTkCUIFRn9G88jPDeEE7P7VbDKbm7ZnzFEhBBBm7oVA81nOGrRYx
SSBIde/W53WnpiA0KZ9o8/fx+PDiy4MerL5nphsxKVcBeP21gThodGlCM5JhZy5Slr
FKs0LKMdEIiAgLq4ykiNEki9Y95w/Hd2hOV0Ms6smyEkvWSa1CGvjceFLfPnOE/PM6
c+6yktTzSUcAb3CkUNrsBstzVKXQTwxLcMIUSSAyoxOE1fy8B/H+8Eq1cUpyG5XokT
DADuQ/y/qdxeA==
Received: from mail.example.test (localhost [IPv6:::1])
(Authenticated sender: [email protected])
by mail.example.test (Postfix) with ESMTPA id 81A3A240A86
for <[email protected]>; Mon, 22 Sep 2025 01:32:14 +0000 (UTC)
Date: Mon, 22 Sep 2025 01:32:14 +0000
To: [email protected]
From: [email protected]
Subject: test Mon, 22 Sep 2025 01:32:14 +0000
X-MS-Reactions: disallow
Message-Id: <[email protected]>
This is a test mailing |
Beta Was this translation helpful? Give feedback.


It should default to
mailAFAIK.You can set this to a custom selector instead, so that you could re-use the
dkimselector you already were using in DNS 👍setup dkim config helpwill output:So all you would need to do is run this to generate with a custom selector
dkim:But this would be generating config at
/tmp/docker-mailserver/opendkimfor new DKIM keys (or/tmp/docker-mailserver/rspamdforENABLE_RSPAMD=1+ENABLE_OPENDKIM=0), so if you want to use your own existing one(s) you'd need to modify what was generated there before you restart DMS …