# Relaying one domain through Amazon SES: MiaB's DKIM signature always fails (SES rewrites Date). Is a custom master.cf transport safe across upgrades?

**URL:** <https://discourse.mailinabox.email/t/relaying-one-domain-through-amazon-ses-miabs-dkim-signature-always-fails-ses-rewrites-date-is-a-custom-master-cf-transport-safe-across-upgrades/17013>\
**Category:** Help with Unusual Circumstances\
**Created:** [October 5, 2026, 9:07pm UTC](https://discourse.mailinabox.email/t/relaying-one-domain-through-amazon-ses-miabs-dkim-signature-always-fails-ses-rewrites-date-is-a-custom-master-cf-transport-safe-across-upgrades/17013 "2026-10-05T21:07:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kprzyb](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/k/9dc877/32.png) [@kprzyb](https://discourse.mailinabox.email/u/kprzyb)\
**Post date:** [October 5, 2026, 9:07pm UTC](https://discourse.mailinabox.email/t/relaying-one-domain-through-amazon-ses-miabs-dkim-signature-always-fails-ses-rewrites-date-is-a-custom-master-cf-transport-safe-across-upgrades/17013/1 "2026-10-05T21:07:43Z")

</div>

Hi all,

I’m running Mail-in-a-Box v77 on Ubuntu 22.04 (Postfix 3.6). One of my domains ([programistok.org](http://programistok.org)) sends outbound mail through Amazon SES (eu-central-1). The other domains on the box are unaffected. Routing is per sender domain: `sender_dependent_relayhost_maps` plus SASL credentials per domain in `main.cf`. Easy DKIM is enabled in SES, so DMARC passes.

**The problem:** every message ends up with a broken MiaB DKIM signature. OpenDKIM signs with selector `mail` (`h=From:To:Subject:Date:From`), and SES then rewrites the `Date` header to UTC and replaces `Message-ID`. That’s documented behaviour; AWS explicitly says not to sign `Date`/`Message-ID`. In a test, `17:06:25 +0200` arrived as `15:06:25 +0000`. Recipients therefore see `dkim=fail` for `d=programistok.org; s=mail` next to `dkim=pass` for the SES signatures. DMARC is fine, but I’d rather not ship a broken signature on every message.

**Why not just disable signing for that domain in OpenDKIM:** Postfix picks the relay by envelope sender, but OpenDKIM signs by the `From:` header. Mail with `From: …@programistok.org` and a different envelope sender still goes out directly from the box and needs the MiaB signature. Examples are Sieve vacation replies (envelope `<>`, since `sieve_vacation_send_from_recipient` is not set) and a couple of addresses I deliberately exclude from the relay.

**What I’m planning:** strip the MiaB signature only from messages actually being handed to SES, at delivery time:

1. A second `smtp` client service in `master.cf`, an exact copy of the default `smtp/unix` line (same columns), plus two overrides:

```auto
ses unix ... smtp
  -o syslog_name=postfix/ses
  -o smtp_header_checks=pcre:/etc/postfix/ses_strip_miab_dkim

```

2. In `main.cf`, `sender_dependent_default_transport_maps = hash:/etc/postfix/relay_transport`:

```auto
relay@programistok.org DUNNO
@programistok.org ses:[email-smtp.eu-central-1.amazonaws.com]:587

```

3. `/etc/postfix/ses_strip_miab_dkim`, which removes only our own signature and leaves any third-party signature on forwarded mail intact:

```auto
/^DKIM-Signature:(?=.*\bd=programistok\.org;)(?=.*\bs=mail;)/ IGNORE

```

OpenDKIM, Dovecot and the MiaB config files themselves stay untouched. I’ll test the whole flow in a local Postfix 3.6 container before deploying.

**My questions:**

1. **Upgrades:** does `setup/start` (or anything in daily tasks) rewrite `master.cf` wholesale, or only the services it manages? From reading `setup/mail-postfix.sh` it looks like MiaB only edits its own entries via `editconf.py -s -w` (`smtps`, `submission`, `authclean`). Would an extra `ses` service survive an upgrade? In my experience the v77 upgrade kept my relay settings in `main.cf` but reverted my TLS hardening, so I’d like to know what to expect here. (I’ll keep a re-apply script and an alert either way.)
2. **Approach:** has anyone else relaying through SES (or another provider that rewrites headers) dealt with this, and solved it differently? Is there something simpler I’m missing, for example making OpenDKIM skip `Date` for one domain only?
3. Any obvious pitfalls with `sender_dependent_default_transport_maps` on a MiaB box? As f `sender_dependent_relayhost_maps`, which is why the exceptions are repeated as `DUNNO`.

I know relaying is outside what MiaB supports, so thanks for any pointers.

---

<div class="post-metadata">

**Author:** ![KiekerJan](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/kiekerjan/32/2339_2.png) [@KiekerJan](https://discourse.mailinabox.email/u/KiekerJan)\
**Post date:** [October 6, 2026, 10:14am UTC](https://discourse.mailinabox.email/t/relaying-one-domain-through-amazon-ses-miabs-dkim-signature-always-fails-ses-rewrites-date-is-a-custom-master-cf-transport-safe-across-upgrades/17013/2 "2026-10-06T10:14:14Z")

</div>

As you’ve stated, you’re on your own with this. I can say that at this time, the mailinabox setup edits only the variables it wants to set in main.cf and master.cf. It does not rewrite the whole file. Meaning a new service in master.cf should survive a upgrade.  
I don’t have answers for your other questions, only that you might be better of asking them at a forum more focussed at postfix.

---

<div class="post-metadata">

**Author:** ![kprzyb](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/k/9dc877/32.png) [@kprzyb](https://discourse.mailinabox.email/u/kprzyb)\
**Post date:** [October 6, 2026, 6:51pm UTC](https://discourse.mailinabox.email/t/relaying-one-domain-through-amazon-ses-miabs-dkim-signature-always-fails-ses-rewrites-date-is-a-custom-master-cf-transport-safe-across-upgrades/17013/3 "2026-10-06T18:51:00Z")

</div>

Thanks @KiekerJan, that was the key piece. Follow-up for anyone who finds this thread:

I went ahead with the plan and it’s now in production. What I ended up with:

- Postfix master config: an extra `ses` service, an exact copy of the stock `smtp/unix` line, plus `-o smtp_header_checks=pcre:/etc/postfix/ses_bez_dkim_miab -o syslog_name=postfix/ses` (created with `postconf -M` / `postconf -P`, so re-running it is idempotent).
- Postfix main config: `sender_dependent_default_transport_maps = hash:/etc/postfix/relay_transport`, mapping `@<domain>` to `ses:[<SES SMTP endpoint>]:587`; the exception addresses are listed as `DUNNO`. The null sender (`<>`, e.g. vacation replies) has no entry, so it still goes direct with the MiaB signature.
- The header check removes only our own signature: `/^DKIM-Signature:(?=.*\bd=<domain>;)(?=.*\bs=mail;)/ IGNORE` (dots in the domain escaped). One pitfall: don’t add the `s` flag. In Postfix pcre tables DOTALL is on by default and `s` turns it _off_, so a folded signature (`s=mail;` on the continuation line) would slip through.

Things that worked without changes:

- `smtp_sender_dependent_authentication` still picks the right SASL credentials when the nexthop comes from the transport map.
- The `smtp_tls_policy_maps` entry for the SES endpoint still applies.

Before deploying I tested it in an Ubuntu 22.04 / Postfix 3.6 container with the editconf tool from MiaB v77. The tests covered SES vs. direct routing, vacation `<>`, the exceptions, folded signatures, and a third-party signature with selector `mail` (which is kept).

Result: Gmail now shows exactly two signatures (SES Easy DKIM for my domain + the amazonses one), both pass, DMARC pass, no more `dkim=fail`. Other domains on the box are unchanged.

Since an upgrade could still touch it, an hourly check alerts me if the `ses` service or its header check goes missing, and my post-upgrade script re-applies everything.

(Small correction to my first post: question 3 lost half a sentence. It should read “As far as I understand, it overrides `sender_dependent_relayhost_maps`, which is why the exceptions are repeated as `DUNNO`.”)
