I’m looking for some method to check, and test and debug SIEVE scripts as my scripts are getting a tad more complex.
Is there a way in Stalwart to test the execution of sieve scripts with sample input?
What other SIEVE editor and debuggers are other using?
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
This doesn’t mention any sandbox/test-run feature. Let me check if the CLI has a sieve test command or the WebUI has a testing tool, and check event logging for tracing.
I have enough grounded info now to answer.
Stalwart doesn’t ship a full sample-input sieve simulator, but it does provide syntax/validation checking and detailed runtime tracing you can use for debugging:
Syntax validation without running against real mail
Over ManageSieve: use the CHECKSCRIPT command to validate a script’s syntax before saving it (returns OK or NO with an error).
Over JMAP for Sieve (RFC 9661): the SieveScript/validate method checks a script without storing it.
The WebUI’s Sieve script editor (under Settings › Sieve, both for user scripts and trusted/system scripts) calls this validation as you save, so syntax errors show up immediately.
Debugging actual execution
There’s no “dry run with a sample email” feature, but Sieve execution emits detailed sieve.* trace events (e.g. sieve.action-accept, sieve.action-reject, sieve.action-discard, sieve.send-message, etc.) at debug/info level. If you set a tracer level to debug or trace, you can watch exactly which Sieve actions fire as real messages flow through the trusted (SMTP) or untrusted (user) interpreter, which is the closest thing to a live debugger. See the full list of Sieve-related events at /docs/ref/events#sieve.
There is no third-party or bundled visual Sieve test/editor tool documented for Stalwart beyond the built-in WebUI editor and ManageSieve/JMAP validation; for building/testing scripts offline before upload, people generally rely on standard Sieve syntax checkers plus these validate endpoints.
For syntax and compile validation there are a few options: a ManageSieve client’s CHECKSCRIPT against the server, or just saving via the WebUI or PUTSCRIPT, both of which reject a script that doesn’t compile. If you’re not already running a ManageSieve listener, enable one on port 4190 (ManageSieve | Stalwart).
There isn’t a built-in “run this script against a sample message” tester today, though. The practical approach is a throwaway test account: send crafted messages and watch what happens with tracing turned up, which shows you which rules and actions fired. Standard user scripts are ordinary RFC 5228 plus common extensions, so a generic Sieve editor will validate the syntax, but anything using Stalwart’s own expression extensions won’t validate in external tools.