Added sieve rule to change mail subject

This commit is contained in:
2024-10-07 17:09:42 +02:00
parent a41cf6eb0a
commit 3e8f920ac3

View File

@@ -1,6 +1,6 @@
# Sieve # Sieve
### Sieve rule to automatically sort mails by alias ### Rule to automatically sort mails by alias
This Sieve rule filters mails by the mail alias they were sent to. This Sieve rule filters mails by the mail alias they were sent to.
Specifically, it uses a custom suffix separated by a dot: `.([0-9a-zA-Z]*)` Specifically, it uses a custom suffix separated by a dot: `.([0-9a-zA-Z]*)`
@@ -17,3 +17,23 @@ if allof (header :regex "to" "^<name>.([0-9a-zA-Z]*)@<domain.tld>$")
stop; stop;
} }
``` ```
### Rule to change Subject of a mail on server
My alma mater introduced a change that subjects of all "external" mails are prefixed with `[Extern]`.
I don't like that so I wrote a Sieve rule to remove it. The rule relies on some functions which need to be `required`.
```
require ["fileinto", "editheader", "variables", "regex"];
if allof (header :contains "subject" "[Extern]")
{
# Match the subject w/o "[Extern]"
if header :regex "Subject" "^\\[Extern\\] (.*)$" {
# Delete header
deleteheader "Subject";
# Add stripped header again
addheader :last "Subject" "${1}";
}
}
```