Sieve body test

@lbutlr kremels at kreme.com
Tue Nov 10 02:36:19 EET 2020


On 09 Nov 2020, at 14:45, Stephan Bosch <stephan at rename-it.nl> wrote:
> 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.

Thanks, I did figure that out. It would be nice if you could somehow set per-user access to certain extensions.

>> 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.

Yes. I originally was thinking I would be able to do the substitution in the sieve itself so was searching fo the bit I would be replacing. I don't think it matters either way. The match is successful and the shell script is called.

>> 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.

Yes, it should. It works from the command line, but fails in sieve.

I've put it aside for now, and may just use a milter in postfix to simply strip the HTML portion out of the email entirely, though that is less than ideal.


-- 
'I don't see why everyone depends on me. I'm not dependable. Even I
	don't depend on me, and I'm me.'



More information about the dovecot mailing list