Creating Sieve scripts

There are plenty of script examples out there. I’ve written code for years. I am not having any luck getting a script to work though. I’m using the app at https://github.com/thsmi/sieve/releases to connect and create the scripts. There does not seem to be a way to tell if the script has been successfully added to my Helm, or if it’s executing. Does anyone have some Helm specific script examples that are working? I’m seeing multiple ways of using the fileinto. Which one is correct, “INBOX.spam”, “spam”, “INBOX/spam”, “\spam”? So it may be a case of incorrect syntax, but no way to verify that. I’ve tried them all.

I’ll share what I’m working on, if I can actually get things working. Any input is appreciated.

I’ve used both sieve-connect (unix cli) and the referenced app, both work well. I also suggest keeping a copy of your sieve rules in git, or similar.

My require at the top

require [ "date", "envelope", "fileinto", "imap4flags", "mailbox", "regex", "reject", "subaddress", "variables"];

An example of how I’m using fileinto

# Do Junk filtering first
if anyof (header :is "X-Spam-Flag" "YES", header :is "X-Spam-Status" "Yes", header :contains "X-Spam-Level" "********" ) {
        setflag "\\Seen";
        fileinto "Spam";
        stop;
}

You can also do things like

# get current date for later use
if currentdate :matches "year" "*" {
        set "year" "${1}";
}
if currentdate :matches "month" "*" {
        set "month" "${1}";
}

and then reference them in your fileinto

# rule:[Juniper]
if allof (header :contains "List-Id" "juniper-nsp.puck.nether.net") {
        fileinto :create "Lists.${year}.${month}.Juniper-NSP";
        stop;
}

Here is example output from sieve-connect

[user@host]$ sieve-connect --server helm.cmhome --notlsverify --user=user@domain.tld --port 4190
Sieve/IMAP Password:
ReadLine support enabled.
> ?
activate ..... <script> -- set the currently used script
checkscript .. <filename> -- check script on the server
deactivate ... turn off sieve processing
delete ....... <script> -- remove the script from the server
               aka: rm
download ..... <script> [<filename>] -- retrieve script from server
               aka: get
edit ......... <script> -- retrieve, edit, check, put script
help ......... this help
               aka: ?
keywords ..... list %KEYWORD substitutions
lcd .......... local cd: change local working directory
list ......... list the scripts currently on the server
               aka: dir ls
lls .......... local ls: look at local filesystem
lpwd ......... local pwd: show local working directory name
man .......... see docs
quit ......... goodbye!
               aka: bye exit logout
upload ....... <filename> [<scriptname>] -- put script on server
               aka: put
view ......... <script> -- show contents of script
               aka: more page show
> list
"user.sieve" ACTIVE
>
2 Likes

Thanks. I had to update WSL since I run Windows generally. Once I did that and installed the seive-connect I was able to debug and could see what was actually going on. It seems the scripts don’t like the “\” on some statements. At this point I’m using;
if address :domain :matches [“from”] [".xyz", ".shop", “.co",".us”,".biz",".info",".click",".uno",".cyou",".buzz",".work",".cam","*.bond"]
to move most of the garbage.

1 Like