Hello,
I want to specify a user sieve script using the json file. Unfortunately, i havent been to find a way to do that.
Here is my workaround,
SIEVE_SCRIPT='require ["fileinto", "mailbox", "imap4flags"];
if header :contains "X-Spam-Status" "Yes" {
fileinto :create "Junk Mail";
setflag "\\Seen";
stop;
}'
# Upload Sieve script content as a blob (binary content)
BLOB_RESPONSE=$(curl -s -u "[email protected]:$STALWART_CONTACT_PASSWORD" \
-X POST "$STALWART_URL/jmap/upload/$CONTACT_ACCOUNT_ID/" \
-H 'Content-Type: application/sieve' \
--data-binary "$SIEVE_SCRIPT")
SIEVE_RESULT=$(curl -s -u "[email protected]:$STALWART_CONTACT_PASSWORD" \
-X POST "$STALWART_URL/jmap" \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"SieveScript/set",
{
"create": {
"spam-filter": {
"name": "spam-filter",
"blobId": "'"$BLOB_ID"'",
"isActive": true
}
}
},
"c1"
]
],
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:sieve"]
}')
if echo "$SIEVE_RESULT" | grep -q '"created"'; then
echo "Spam filter Sieve script created and activated"
else
echo "Warning: Sieve script creation may have failed"
echo "Response: $SIEVE_RESULT"
fi
Is it possible to specify in the json file, so i can use stalwart-cli apply to upload it instead of using a script?