I have an email where I need to edit the body. I know this is generally a bad idea, but in this case I need to do it. The email comes in automatically every week or two, and so I thought that SIEVE would be the way to go.
if header :contains "from" "theaddress@tehdomain" { if body :raw :contains "A string" { # Magic happens here } }
It looks like what I need to do is enable and use vnd.dovecot.filter to pipe the message to a script. (Er. | not vnd.dovecot.pipe)
So, if I wanted to transform the message so that the string "foobar13" was changed to "foo-bar-13"
I would add
filter :try "myfoobarfix.sh"
After "magic happens here">
OK so far?
Now, what are the requirements on the executable script? Would it literally be as simple as an executable file that simply said
sed -e '|foobar13|foo-bar-13|g'
Or does it need to be a shebang script and take input on $1 and … ?
And lastly, where do the executable scripts need to be? https://raw.githubusercontent.com/dovecot/pigeonhole/master/doc/rfc/spec-bos... says "the external programs cannot be chosen arbitrarily; the available programs are restricted through administrator configuration", but no details on exactly how that is configured.
-- "Are you pondering what I'm pondering?" Pinky: I think so, Brain. But if I put on two tutu's, would I really be wearing a four-by-four? Brain: Why do I even bother asking? Pinky: I dunno, Brain. Maybe it's all part of some huge, cosmic plot formula!
On 20 Oct 2020, at 13:46, @lbutlr kremels@kreme.com wrote:
It looks like what I need to do is enable and use vnd.dovecot.filter
error: require command: unknown Sieve capability `vnd.dovecot.filter'.
Is this not available to a user? I guess I can put the in global, but ick.
-- he'd moved like music, like someone dancing to a rhythm inside his head. And his face for a moment in the moonlight was the skull of an angel...
On 20/10/2020 23:37, @lbutlr wrote:
On 20 Oct 2020, at 13:46, @lbutlr kremels@kreme.com wrote:
It looks like what I need to do is enable and use vnd.dovecot.filter error: require command: unknown Sieve capability `vnd.dovecot.filter'.
Is this not available to a user? I guess I can put the in global, but ick.
You need to include the extprograms plugin:
https://doc.dovecot.org/configuration_manual/sieve/plugins/extprograms/
The language extension is described here:
https://raw.githubusercontent.com/dovecot/pigeonhole/master/doc/rfc/spec-bos...
Regards,
Stephan.
On 22 Oct 2020, at 19:09, Stephan Bosch stephan@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.
-- Romy: All I've had to eat for the past six days are Gummi Bears, jelly beans, and candy corns. Michelle: I wish I had your discipline.
On 23/10/2020 13:22, @lbutlr wrote:
On 22 Oct 2020, at 19:09, Stephan Bosch stephan@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).
Regards,
Stephan.
On 26 Oct 2020, at 21:04, Stephan Bosch stephan@rename-it.nl wrote:
On 23/10/2020 13:22, @lbutlr wrote:
On 22 Oct 2020, at 19:09, Stephan Bosch stephan@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?
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"; } }
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)
-- [Unused] "Are you pondering what I'm pondering?"
Pinky: I think so, Brain, but she'd never leave Mickey. Brain: I thought we agreed never to discuss that!
On 27/10/2020 15:30, @lbutlr wrote:
On 26 Oct 2020, at 21:04, Stephan Bosch stephan@rename-it.nl wrote:
On 23/10/2020 13:22, @lbutlr wrote:
On 22 Oct 2020, at 19:09, Stephan Bosch stephan@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.
On 09 Nov 2020, at 14:45, Stephan Bosch stephan@rename-it.nl wrote:
On 27/10/2020 15:30, @lbutlr wrote:
On 26 Oct 2020, at 21:04, Stephan Bosch stephan@rename-it.nl wrote:
On 23/10/2020 13:22, @lbutlr wrote:
On 22 Oct 2020, at 19:09, Stephan Bosch stephan@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.'
participants (2)
-
@lbutlr
-
Stephan Bosch