MtaHook
MtaHook
Section titled “MtaHook”Defines an MTA hook endpoint for message processing.
This object can be configured from the WebUI under Settings › MTA › Filters › MTA Hooks
Fields
Section titled “Fields”allowInvalidCerts
Section titled “allowInvalidCerts”Type:
Boolean· default:falseWhether Stalwart should connect to a hook server that has an invalid TLS certificate
enable
Section titled “enable”Type:
Expression· default:{"else":"true"}Expression that determines whether to enable this hook
Available variables:
MtaRcptToVariable.
maxResponseSize
Section titled “maxResponseSize”Type:
Size· default:52428800Maximum size, in bytes, of a response that Stalwart will accept from this MTA Hook server
tempFailOnError
Section titled “tempFailOnError”Type:
Boolean· default:trueWhether to respond with a temporary failure (typically a 4xx SMTP status code) when Stalwart encounters an error while communicating with this MTA Hook server
stages
Section titled “stages”Type:
MtaStage[]· default:["data"]Which SMTP stages to run this hook on
timeout
Section titled “timeout”Type:
Duration· default:"30s"Maximum amount of time that Stalwart will wait for a response from this hook server
Type:
Uri· requiredURL of the hook endpoint
httpAuth
Section titled “httpAuth”Type:
HttpAuth· requiredThe type of HTTP authentication to use
httpHeaders
Section titled “httpHeaders”Type:
Map<String, String>Additional headers to include in HTTP requests
JMAP API
Section titled “JMAP API”The MtaHook object is available via the urn:stalwart:jmap capability.
x:MtaHook/get
Section titled “x:MtaHook/get”This is a standard Foo/get method as defined in RFC 8620, Section 5.1.
This method requires the sysMtaHookGet permission.
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" ] }'x:MtaHook/set
Section titled “x:MtaHook/set”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.
Create
Section titled “Create”This operation requires the sysMtaHookCreate permission.
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" ] }'Update
Section titled “Update”This operation requires the sysMtaHookUpdate permission.
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" ] }'Destroy
Section titled “Destroy”This operation requires the sysMtaHookDestroy permission.
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" ] }'x:MtaHook/query
Section titled “x:MtaHook/query”This is a standard Foo/query method as defined in RFC 8620, Section 5.5.
This method requires the sysMtaHookQuery permission.
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.
stalwart-cli get MtaHook id1Create
Section titled “Create”stalwart-cli create MtaHook \ --field url=https://example.com \ --field 'httpAuth={"@type":"Unauthenticated"}' \ --field 'httpHeaders={}'stalwart-cli query MtaHookUpdate
Section titled “Update”stalwart-cli update MtaHook id1 --field allowInvalidCerts=falseDelete
Section titled “Delete”stalwart-cli delete MtaHook --ids id1Nested types
Section titled “Nested types”Expression
Section titled “Expression”A conditional expression with match rules and a default value.
Type:
ExpressionMatch[]List of conditions and their corresponding results
Type:
String· requiredElse condition
ExpressionMatch
Section titled “ExpressionMatch”A single condition-result pair in an expression.
Type:
String· requiredIf condition
Type:
String· requiredThen clause
HttpAuth
Section titled “HttpAuth”Defines the HTTP authentication method to use for HTTP requests.
Unauthenticated: Anonymous. No additional fields.Basic: Basic Authentication. Carries the fields ofHttpAuthBasic.Bearer: Bearer Token. Carries the fields ofHttpAuthBearer.
HttpAuthBasic
Section titled “HttpAuthBasic”HTTP Basic authentication credentials.
username
Section titled “username”Type:
String· requiredUsername for HTTP Basic Authentication
secret
Section titled “secret”Type:
SecretKey· requiredPassword for HTTP Basic Authentication
SecretKey
Section titled “SecretKey”A secret value provided directly, from an environment variable, or from a file.
Value: Secret value. Carries the fields ofSecretKeyValue.EnvironmentVariable: Secret read from environment variable. Carries the fields ofSecretKeyEnvironmentVariable.File: Secret read from file. Carries the fields ofSecretKeyFile.
SecretKeyValue
Section titled “SecretKeyValue”A secret value provided directly.
secret
Section titled “secret”Type:
String· required · secretPassword or secret value
SecretKeyEnvironmentVariable
Section titled “SecretKeyEnvironmentVariable”A secret value read from an environment variable.
variableName
Section titled “variableName”Type:
String· requiredEnvironment variable name to read the secret from
SecretKeyFile
Section titled “SecretKeyFile”A secret value read from a file.
filePath
Section titled “filePath”Type:
String· requiredFile path to read the secret from
HttpAuthBearer
Section titled “HttpAuthBearer”HTTP Bearer token authentication.
bearerToken
Section titled “bearerToken”Type:
SecretKey· requiredBearer token for HTTP Bearer Authentication
MtaStage
Section titled “MtaStage”| Value | Label |
|---|---|
connect | Connect |
ehlo | EHLO |
auth | AUTH |
mail | MAIL FROM |
rcpt | RCPT TO |
data | DATA |
Expression references
Section titled “Expression references”The following expression contexts are used by fields on this page:
MtaRcptToVariable(Variables)