You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/momentum/3/3-api/hooks-core-final-validation.md
+36-10Lines changed: 36 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
---
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)."
5
5
---
6
6
7
7
<aname="hooks.core.final_validation"></a>
8
8
## Name
9
9
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
11
11
12
12
## Synopsis
13
13
@@ -18,13 +18,15 @@ final_validation — This hook is invoked after the normal validation steps
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.
@@ -66,11 +68,35 @@ The `validate_context` struct. For documentation of this data structure see [“
66
68
67
69
**<aname="idp45864272"></a> Return Values**
68
70
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.
0 commit comments