Sieve body test
Stephan Bosch
stephan at rename-it.nl
Mon Nov 9 23:45:42 EET 2020
On 27/10/2020 15:30, @lbutlr wrote:
> On 26 Oct 2020, at 21:04, Stephan Bosch <stephan at rename-it.nl> wrote:
>> On 23/10/2020 13:22, @lbutlr wrote:
>>> On 22 Oct 2020, at 19:09, Stephan Bosch <stephan at rename-it.nl> wrote:
>>>> You need to include the extprograms plugin:
>>> I have, and vnf.dovecot.pipe doesn't give the error.
>>>
>>> sieve_plugins = sieve_imapsieve sieve_extprograms
>>>
>>> ¯\_(ツ)_/¯
>>>
>>> I am not using filter now though, so I haven't try to track down what the issue is.
>> And you also need to add vnd.dovecot.filter to sieve_extensions (or sieve_global_extensions).
> Ah, yes, so I do. I only had .pipe there. While I am here, does _global_ mean that they do not need to be listed in the requires header?
No, it means it can only be used from global (administrator-controlled)
scripts, like those configured for sieve_before/sieve_after. So, the
normal user scripts that are uploaded through ManageSieve cannot use it
when it is only listed as global.
If you want implicit availability without require, you'll need to add it
to sieve_implicit_extensions=. However, such a configuration is
non-standard and therefore not recommended (only to provide migration
from other Sieve interpreters that didn't follow the standard very closely).
> That's good, I'm working on a. Filter to restyle some html emails that I get to eliminate the white backgrounds, and filter is going to be necessary for that to work.
>
> Something along the lines of
>
> if allof ( header :contains "from" "someone",
> header :contains "to" "me".
> Header :contains "Subject" "Stupid HTML" ) {
>
> if body :raw :contains "</head>" {
> filter :try "darkmode.sh";
> }
> }
You could also check the content-type header, rather than inspecting the
body for a tell-tale HTML tag.
> darkmode.sh:
> #!/bin/sh
> sed -e '|</head>|<style>* {color:white !important; background-color: black !important; } </style></head>|'
>
> (Not that I have even begun to test that)
>
I am not too familiar with sed, but as long as this script reads the raw
mail from stdin and writes the modified mail to stdout, it should work.
Regards,
Stephan.
More information about the dovecot
mailing list