Skip to content

Commit 5e939d8

Browse files
authored
DKIM2
Signed-off-by: Doug Koerich <douglas.koerich@bird.com>
1 parent 864e4f3 commit 5e939d8

7 files changed

Lines changed: 1278 additions & 10 deletions

File tree

content/momentum/3/3-api/hooks-core-final-validation.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
lastUpdated: "03/26/2020"
3-
title: "final_validation"
4-
description: "final validation This hook is invoked after the normal validation steps void core final validation closure msg ac ctx void closure ec message msg accept construct ac validate context ctx This hook is invoked after the normal validation steps have completed and is the recommended hook point to implement message..."
2+
lastUpdated: "07/07/2026"
3+
title: "final_validation / final_validation2"
4+
description: "final validation This hook is invoked after the normal validation steps and is the recommended hook point to implement message signing prior to spooling. Two variants exist: core_final_validation (void) and core_final_validation2 (returns a status so a signer can fail or tempfail the message)."
55
---
66

77
<a name="hooks.core.final_validation"></a>
88
## Name
99

10-
final_validation — This hook is invoked after the normal validation steps
10+
final_validation, final_validation2 — This hook is invoked after the normal validation steps
1111

1212
## Synopsis
1313

@@ -18,13 +18,15 @@ final_validation — This hook is invoked after the normal validation steps
1818
|   | <var class="pdparam">ac</var>, |   |
1919
|   | <var class="pdparam">ctx</var>`)`; |   |
2020

21+
| `int **core_final_validation2** (` | <var class="pdparam">closure</var>, | |
22+
| | <var class="pdparam">msg</var>, | |
23+
| | <var class="pdparam">ac</var>, | |
24+
| | <var class="pdparam">ctx</var>`)`; | |
25+
2126
`void * <var class="pdparam">closure</var>`;
2227
`ec_message * <var class="pdparam">msg</var>`;
2328
`accept_construct * <var class="pdparam">ac</var>`;
24-
`validate_context * <var class="pdparam">ctx</var>`;<a name="idp45851968"></a>
25-
## Description
26-
27-
This hook is invoked after the normal validation steps have completed and is the recommended hook point to implement message signing prior to spooling the message to disk and attempting delivery.
29+
`validate_context * <var class="pdparam">ctx</var>`;<a name="idp45851968"></a>
2830

2931
**<a name="idp45853360"></a> Parameters**
3032

@@ -66,11 +68,35 @@ The `validate_context` struct. For documentation of this data structure see [“
6668

6769
**<a name="idp45864272"></a> Return Values**
6870

69-
This hook returns `void`.
71+
`core_final_validation` returns `void`.
72+
73+
`core_final_validation2` returns an `int` status:
74+
75+
| Value | Constant | Meaning |
76+
|---|---|---|
77+
| `0` | `EC_HOOK_CONT` | Success — continue. Use this even after a *non-fatal* failure if you want the message delivered unsigned rather than rejected. |
78+
| `1` | `EC_HOOK_DONE` | Error — reject the message (permanent failure). |
79+
| `2` | `EC_HOOK_RETRY` | Temporary error — defer the message; delivery may be retried. |
80+
81+
## Description
82+
83+
This hook is invoked after the normal validation steps have completed and is the recommended hook point to implement message signing prior to spooling the message to disk and attempting delivery.
84+
85+
It fires on **every injection path** — the same point terminates both the SMTP/relay reception sequence and the HTTP/`msg_gen` (transmissions) generation sequence (see [Policy Phases](/momentum/4/4-policy)). This makes it the natural place for signing that must apply regardless of how a message entered Momentum, in contrast to the `validate_data_spool` / `validate_data_spool_each_rcpt` hooks, which are driven only by the SMTP swap-out engine and therefore never fire on the `msg_gen` path.
86+
87+
### final_validation vs. final_validation2
88+
89+
Two variants of this hook exist at the same point:
90+
91+
- **`core_final_validation`** — the original hook. Returns `void`; it cannot signal a result back to the caller, so a failure inside it cannot reject or defer the message.
92+
- **`core_final_validation2`** — an extended variant that returns an `int` status (see *Return Values* below), letting a caller **fail (reject) or tempfail (retry)** the message when the validation fails.
93+
94+
*Both variants are invoked* at the same point; `core_final_validation2` is called **first**, and if it returns `EC_HOOK_DONE`/`EC_HOOK_RETRY` the message is rejected/deferred before `core_final_validation` runs. Existing `void` signers registered on `core_final_validation` continue to work unchanged. The [`post_final_validation`](/momentum/4/hooks/core-post-final-validation) hook runs after both.
7095

7196
**<a name="idp45865632"></a> Threading**
7297

7398
This hook will be called in any thread.
7499

75100
<a name="idp45866720"></a>
76-
## See Also
101+
102+
## See Also

0 commit comments

Comments
 (0)