Sample jMilter request for the DATA
stage:
{
"context": {
"stage": "DATA",
"sasl": {
"login": "user",
"method": "plain"
},
"client": {
"ip": "192.168.1.1",
"port": 34567,
"ptr": "mail.example.com",
"ehlo": "mail.example.com",
"activeConnections": 1
},
"tls": {
"version": "1.3",
"cipher": "TLS_AES_256_GCM_SHA384",
"cipherBits": 256,
"certIssuer": "Let's Encrypt",
"certSubject": "mail.example.com"
},
"server": {
"name": "Stalwart Mail Server",
"port": 25,
"ip": "192.168.2.2"
},
"queue": {
"id": "1234567890"
},
"protocol": {
"version": "1.0"
}
},
"envelope": {
"from": {
"address": "[email protected]",
"parameters": {
"size": 12345
}
},
"to": [
{
"address": "[email protected]",
"parameters": {
"orcpt": "rfc822; [email protected]"
}
},
{
"address": "[email protected]",
"parameters": null
}
]
},
"message": {
"headers": [
[
"From",
"John Doe <[email protected]>"
],
[
"To",
"Bill <[email protected]>, Jane <[email protected]>"
],
[
"Subject",
"Hello, World!"
]
],
"serverHeaders": [
[
"Received",
"from mail.example.com (mail.example.com [192.168.1.1]) by mail.foobar.com (Stalwart Mail Server) with ESMTPS id 1234567890"
]
],
"contents": "Hello, World!\r\n",
"size": 12345
}
}
Notes:
- HTTP
POST
requests are used with authentication being optional. - Message bodies are provided raw as content filters usually need to analyse the MIME structure as well.
- jMilters can be called from any stage of the SMTP transaction so most of these fields are optional.
message.headers[][]
is an array of arrays to keep the JSON representation compact. This can be changed to an array of objects if needed.
What does it mean to replaceBody? A plain body only or to provide all body alternatives? It is not clear to me.
Here is a use case example. Imagine a feature 'URL filtering', where all URLs are replaced with an encrypted URL (used like hashes) to the service (and their real values are stored).
On click from an MUA, those encrypted URLs are decrypted, checked with APIs like Google Safe Browsing, and redirected. And there is a need to be replaced both plain and HTML bodies.