Skip to content

MtaHook

Defines an MTA hook endpoint for message processing.

This object can be configured from the WebUI under Settings › MTA › Filters › MTA Hooks

Type: Boolean · default: false

Whether Stalwart should connect to a hook server that has an invalid TLS certificate

Type: Expression · default: {"else":"true"}

Expression that determines whether to enable this hook

Available variables: MtaRcptToVariable.

Type: Size · default: 52428800

Maximum size, in bytes, of a response that Stalwart will accept from this MTA Hook server

Type: Boolean · default: true

Whether to respond with a temporary failure (typically a 4xx SMTP status code) when Stalwart encounters an error while communicating with this MTA Hook server

Type: MtaStage[] · default: ["data"]

Which SMTP stages to run this hook on

Type: Duration · default: "30s"

Maximum amount of time that Stalwart will wait for a response from this hook server

Type: Uri · required

URL of the hook endpoint

Type: HttpAuth · required

The type of HTTP authentication to use

Type: Map<String, String>

Additional headers to include in HTTP requests

The MtaHook object is available via the urn:stalwart:jmap capability.

This is a standard Foo/get method as defined in RFC 8620, Section 5.1.

This method requires the sysMtaHookGet permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:MtaHook/get",
{
"ids": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This is a standard Foo/set method as defined in RFC 8620, Section 5.3.

Supports create, update, and destroy operations in a single call.

This operation requires the sysMtaHookCreate permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:MtaHook/set",
{
"create": {
"new1": {
"httpAuth": {
"@type": "Unauthenticated"
},
"httpHeaders": {},
"url": "https://example.com"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This operation requires the sysMtaHookUpdate permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:MtaHook/set",
{
"update": {
"id1": {
"allowInvalidCerts": false
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This operation requires the sysMtaHookDestroy permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:MtaHook/set",
{
"destroy": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This is a standard Foo/query method as defined in RFC 8620, Section 5.5.

This method requires the sysMtaHookQuery permission.

Terminal window
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:MtaHook/query",
{
"filter": {}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

stalwart-cli wraps the same JMAP calls. See the CLI reference for installation, authentication, and general usage.

Terminal window
stalwart-cli get MtaHook id1
Terminal window
stalwart-cli create MtaHook \
--field url=https://example.com \
--field 'httpAuth={"@type":"Unauthenticated"}' \
--field 'httpHeaders={}'
Terminal window
stalwart-cli query MtaHook
Terminal window
stalwart-cli update MtaHook id1 --field allowInvalidCerts=false
Terminal window
stalwart-cli delete MtaHook --ids id1

A conditional expression with match rules and a default value.

Type: ExpressionMatch[]

List of conditions and their corresponding results

Type: String · required

Else condition

A single condition-result pair in an expression.

Type: String · required

If condition

Type: String · required

Then clause

Defines the HTTP authentication method to use for HTTP requests.

  • Unauthenticated: Anonymous. No additional fields.
  • Basic: Basic Authentication. Carries the fields of HttpAuthBasic.
  • Bearer: Bearer Token. Carries the fields of HttpAuthBearer.

HTTP Basic authentication credentials.

Type: String · required

Username for HTTP Basic Authentication

Type: SecretKey · required

Password for HTTP Basic Authentication

A secret value provided directly, from an environment variable, or from a file.

A secret value provided directly.

Type: String · required · secret

Password or secret value

A secret value read from an environment variable.

Type: String · required

Environment variable name to read the secret from

A secret value read from a file.

Type: String · required

File path to read the secret from

HTTP Bearer token authentication.

Type: SecretKey · required

Bearer token for HTTP Bearer Authentication

ValueLabel
connectConnect
ehloEHLO
authAUTH
mailMAIL FROM
rcptRCPT TO
dataDATA

The following expression contexts are used by fields on this page: