So, this is what I did instead of default_sieve:
sieve_before = file:/usr/lib/dovecot/sieve/bcc.sieve sieve_before2 = file:/usr/lib/dovecot/sieve/filespam.sieve
# cat /usr/lib/dovecot/sieve/bcc.sieve require ["variables", "copy"];
if address :matches ["To", "Cc"] ["*@*."] { redirect :copy "backup+295.${1}.${2}@. . ."; }
# cat /usr/lib/dovecot/sieve/filespam.sieve require ["fileinto", "imap4flags"];
if header :contains "X-spam-flag" "YES" { fileinto :flags "\Seen" "Junk"; }
The bcc.sieve file is generated each day with a little script to put in the day of the year, so that for the backup user the folder structure for backups for my list mail is, for example:
295 kremels kreme <messages> otheruser kreme <messages>
And tomorrow new folders for 296 will be created.
So far, I think it's working. 🤞
-- C code. C code run. Run, code, run.
On 21 Oct 2020, at 13:08, @lbutlr kremels@kreme.com wrote:
# cat /usr/lib/dovecot/sieve/bcc.sieve require ["variables", "copy"];
if address :matches ["To", "Cc"] ["*@*."] { redirect :copy "backup+295.${1}.${2}@. . ."; }
…
So far, I think it's working. 🤞
Welp, spoke to soon. I rebooted because of an update to FreeBSD p10 and now the bcc.sieve doesn’t appear to be doing anything, but I am not seeing any errors logged either.
I am wondering about doing something like
If header :matches ["received"] ["for <*@*>"]
To account for list mail properly, but until I know why this is now failing, I feel like I can't do that.
I have trace logs enabled for user scripts, but I think only error get logged for upper level, and only along the lines of "could not compile <name of sieve>".
-- "Some cause happiness wherever they go; others, whenever they go.." - Oscar Wilde
On 10/21/20 1:10 PM, @lbutlr wrote:
I have trace logs enabled for user scripts, but I think only error get logged for upper level, and only along the lines of "could not compile <name of sieve>".
verify that you can compile the scripts manually, even as root
then double-check your perms on your sieve/ dir, making sure that the write perms are correct for your dovecot (other?) sieve processes
On 21 Oct 2020, at 14:35, PGNet Dev pgnet.dev@gmail.com wrote:
On 10/21/20 1:10 PM, @lbutlr wrote:
I have trace logs enabled for user scripts, but I think only error get logged for upper level, and only along the lines of "could not compile <name of sieve>".
verify that you can compile the scripts manually, even as root
Yeah, they compile. If they didn't that would be logged (I know because when I left out a ; I saw that it failed in the log, right now, no logging.
then double-check your perms on your sieve/ dir, making sure that the write perms are correct for your dovecot (other?) sieve processes
Nothing has changed there.
Do I HAVE to have a default.sieve, that's the only thing that I can think the has changed in that folder.
-- The King of Marigold was in the kitchen cooking breakfast for the Queen The Queen was in the parlor playing piano for the children of the King
On 10/21/20 2:12 PM, @lbutlr wrote:
Do I HAVE to have a default.sieve, that's the only thing that I can think the has changed in that folder. RE: compile, fyi note @
https://wiki2.dovecot.org/Pigeonhole/Sieve/Usage#Manually_Compiling_Sieve_Scripts
https://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration#Executing_Multiple_Scripts_Sequentially
the conditions under which you need to manually pre-compile the scripts specified by sieve_before and sieve_after
HAVE to have
In my config, it's def'd, but I don't explicitly _have_ a 'default.sieve'.
& my setup generally works. So far. Whether that's luck or by-design, still remains to be seen; the real-world docs/examples for 'this' are a bit ... sketchy.
fyi, my current dovecot config includes,
protocols = imap submission lmtp sieve
mail_plugins = virtual acl fts fts_solr
protocol sieve {
mail_plugins = $mail_plugins
mail_max_userip_connections = 10
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext vnd.dovecot.pipe vnd.dovecot.filter vnd.dovecot.execute
}
plugin {
imapsieve_mailbox1_name = Junk
imapsieve_mailbox1_causes = COPY
imapsieve_mailbox1_before = file:/etc/dovecot/sieve/global/report-spam.sieve
imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Junk
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before = file:/etc/dovecot/sieve/global/report-ham.sieve
sieve_global = /etc/dovecot/scripts/sieve
sieve = file:/data/sieve/%u/;active=/data/sieve/%u/active.sieve
sieve_default = /data/sieve/default.sieve
sieve_default_name = managesieve
sieve_extensions = +vnd.dovecot.pipe +vnd.dovecot.filter +vnd.dovecot.execute +vnd.dovecot.debug +vnd.dovecot.imapsieve
sieve_pipe_bin_dir = /etc/dovecot/sieve/pipe_bin/
sieve_filter_bin_dir = /etc/dovecot/sieve/filter_bin/
sieve_execute_bin_dir = /etc/dovecot/sieve/execute_bin/
sieve_plugins = sieve_imapsieve sieve_extprograms
}
& my Roundcube config (I use RC for user-friendly Sieve UI; so far, seems best of the bunch) includes
$config['managesieve_raw_editor'] = true;
$config['managesieve_default'] = '/data/sieve/default.sieve';
$config['managesieve_script_name'] = 'managesieve';
and with that^, I do not have a
/data/sieve/default.sieve
instead, I have, for each user@example.com
tree /data/sieve/user@example.com/
/data/sieve/user@example.com/
├── active.sieve -> managesieve.sieve
├── active.svbin
├── managesieve.sieve
└── tmp
i assume i _could_ have/use a default.sieve, but have not yet done so.
On 21 Oct 2020, at 15:45, PGNet Dev pgnet.dev@gmail.com wrote:
On 10/21/20 2:12 PM, @lbutlr wrote:
Do I HAVE to have a default.sieve, that's the only thing that I can think the has changed in that folder. RE: compile, fyi note @
https://wiki2.dovecot.org/Pigeonhole/Sieve/Usage#Manually_Compiling_Sieve_Sc... https://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration#Executing_Multiple_...
the conditions under which you need to manually pre-compile the scripts specified by sieve_before and sieve_after
As I said, the scripts compile just fine.
8 -rw-r--r-- 1 root wheel 117B Oct 21 12:49 filespam.sieve 8 -rw-r--r-- 1 vmail wheel 256B Oct 21 12:52 filespam.svbin 8 -rw-r--r-- 1 root wheel 137B Oct 21 14:06 bcc.sieve 8 -rw-r--r-- 1 vmail wheel 304B Oct 21 14:10 bcc.svbin
protocol sieve { mail_plugins = $mail_plugins mail_max_userip_connections = 10 managesieve_notify_capability = mailto managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext vnd.dovecot.pipe vnd.dovecot.filter vnd.dovecot.execute }
plugin {
imapsieve_mailbox1_name = Junk imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_before = file:/etc/dovecot/sieve/global/report-spam.sieve imapsieve_mailbox2_name = * imapsieve_mailbox2_from = Junk imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_before = file:/etc/dovecot/sieve/global/report-ham.sieve sieve_global = /etc/dovecot/scripts/sieve sieve = file:/data/sieve/%u/;active=/data/sieve/%u/active.sieve sieve_default = /data/sieve/default.sieve sieve_default_name = managesieve sieve_extensions = +vnd.dovecot.pipe +vnd.dovecot.filter +vnd.dovecot.execute +vnd.dovecot.debug +vnd.dovecot.imapsieve sieve_pipe_bin_dir = /etc/dovecot/sieve/pipe_bin/ sieve_filter_bin_dir = /etc/dovecot/sieve/filter_bin/ sieve_execute_bin_dir = /etc/dovecot/sieve/execute_bin/ sieve_plugins = sieve_imapsieve sieve_extprograms
}
I have this in my doveconf -n
managesieve_notify_capability = mailto managesieve_sieve_capability = editheader fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date ihave
plugin { imapsieve_mailbox1_before = file:/usr/lib/dovecot/sieve/report-spam.sieve imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_name = Junk imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_from = Junk imapsieve_mailbox2_name = * imapsieve_mailbox3_before = file:/usr/lib/dovecot/sieve/mark-read.sieve imapsieve_mailbox3_causes = COPY imapsieve_mailbox3_name = Archive last_login_dict = file:~/.lastlogin quota_rule2 = .EXPUNGED:ignore sieve = file:~/.sieve;active=~/.active_sieve sieve_before = file:/usr/lib/dovecot/sieve/bcc.sieve sieve_before2 = file:/usr/lib/dovecot/sieve/filespam.sieve sieve_before3 = file:/usr/lib/dovecot/sieve/darkmode.sieve sieve_default_name = spamassassin sieve_duplicate_default_period = 1h sieve_duplicate_max_period = 12d sieve_extensions = +editheader sieve_plugins = sieve_imapsieve sieve_extprograms sieve_trace_level = matching sieve_user_log = ~/sieve.log }
I do not have a protocol sieve { } section and I have not setup sieve for roundcuve at this point. I do have round cube on my system, but it is basically emergency access and no one uses it as their regular access to mail. I'll get around to it sometime.
The frustrating thing, of course, is that it was working before I rebooted but I can't find any errors logged anywhere.
-- "Are you pondering what I'm pondering?" "Wuhhh... I think so, Brain, but if a ham can operate a radio, why can't a pig set a VCR?"
Something odd happens when I copied and pasted.
On 21 Oct 2020, at 19:05, @lbutlr kremels@kreme.com wrote:
sieve_extensions = +editheader
sieve_extensions = +editheader sieve_filter_bib_dir = /usr/lib/dovecot/sieve sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment sieve_pipe_bin_dir = /usr/lib/dovecot/sieve sieve_plugins = sieve_imapsieve sieve_extprograms sieve_trace_dir = ~/.trace sieve_trace_level = matching sieve_user_log = ~/sieve.log
sieve_trace_level = matching sieve_user_log = ~/sieve.log }
-- "It's like those French have a different word for *everything*" - Steve Martin
On 21 Oct 2020, at 14:10, @lbutlr kremels@kreme.com wrote:
I have trace logs enabled for user scripts, but I think only error get logged for upper level, and only along the lines of "could not compile <name of sieve>".
Any ideas?
Is there a way to force the default and sieve_before scripts to log to syslog?
-- The real world was far too real to leave neat little hints. It was full of too many things. It wasn't by eliminating the impossible that you got at the truth, however improbable; it was by the much harder process of eliminating the possibilities. --Feet of Clay
On 22 Oct 2020, at 09:35, @lbutlr kremels@kreme.com wrote:
Is there a way to force the default and sieve_before scripts to log to syslog?
OK, the "top level" sieves are also logged to the users trace files along with the user's sieve files, if any. So, I am getting this:
3: address test
3: starting :matches' match with
i;ascii-casemap' comparator:
3: extracting To' headers from message 3: parsing address header value
@lbutlr kremels@kreme.com'
3: address value kremels@kreme.com' 3: extracting
all' part from address kremels@kreme.com
3: matching value kremels@kreme.com' 3: with key
*@*.' => 0
3: extracting `Cc' headers from message
3: finishing match with result: not matched
3: jump if result is false
3: jumping to line 4
## Finished executing script 'bcc'
bcc.sieve: require ["variables", "copy"];
if address :matches ["To", "Cc"] ["*@*."] { redirect :copy "backup+295.${1}.${2}@*example.com*"; }
I've obviously done something wrong there, but what? I don't think 'redirect' has any required plugins (or at least I could find no mention of one, maybe it's implied to be part of fileinto?
-- Cause love's such an old fashioned word And love dares you to care for the people on the Edge of the night, and love dares you to change Our way of caring about ourselves, This is our last dance This is ourselves. Under Pressure.
On 22 Oct 2020, at 10:05, @lbutlr
require ["variables", "copy"];
if address :matches ["To", "Cc"] ["*@*."] { redirect :copy "backup+295.${1}.${2}@*example.com*"; }
I have tried this with similar results:
require ["copy", "variables", "envelope", "fileinto", "subaddress"];
if envelope :matches :detail "to" "*" {
set :lower "name" "${1}";
redirect :copy "backup+295.${name}@@*example.com*";
}
## Started executing script 'bcc'
5: envelope test
5: starting `:matches' match with `i;ascii-casemap' comparator:
5: getting `to' part from message envelope
5: extracting `detail' part from address
On Oct 22, 2020, at 12:19, @lbutlr
wrote: On 22 Oct 2020, at 10:05, @lbutlr
wrote: require ["variables", "copy"];
if address :matches ["To", "Cc"] ["*@*."] { redirect :copy "backup+295.${1}.${2}@*example.com*"; }
I have tried this with similar results:
require ["copy", "variables", "envelope", "fileinto", "subaddress"];
if envelope :matches :detail "to" "*" { set :lower "name" "${1}"; redirect :copy "backup+295.${name}@@*example.com*"; }
## Started executing script 'bcc' 5: envelope test 5: starting `:matches' match with `i;ascii-casemap' comparator: 5: getting `to' part from message envelope 5: extracting `detail' part from address
5: finishing match with result: not matched 5: jump if result is false 5: jumping to line 7 ## Finished executing script 'bcc' So why are these not matching? I can see the 'detail' right there, and this matches examples that I see online.
(I've read, I think, every page google or DDG can find that contains "redirect :copy" to no avail).
If I read that bcc trace, it says “extracting ‘detail’ part from address
On 22 Oct 2020, at 15:10, Sean Kamath
On Oct 22, 2020, at 12:19, @lbutlr
wrote: On 22 Oct 2020, at 10:05, @lbutlr
wrote: if address :matches ["To", "Cc"] ["*@*."] {
if envelope :matches :detail "to" "*" { set :lower "name" "${1}"; redirect :copy "backup+295.${name}@@*example.com*"; }
## Started executing script 'bcc' 5: envelope test 5: starting `:matches' match with `i;ascii-casemap' comparator: 5: getting `to' part from message envelope 5: extracting `detail' part from address
5: finishing match with result: not matched 5: jump if result is false 5: jumping to line 7 ## Finished executing script 'bcc'
If I read that bcc trace, it says “extracting ‘detail’ part from address
”.
OK, but that exact line is used in several examples online to get the email address. And it doesn't explain why "if address :matches ["To", "Cc"] ["*@*."] {" also failed to match despite also showing the email address.
“kremels@kreme.com” does not have a :detail part (https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples talks about this).
And I am not asking for :detail, nor am I trying to the the address extension/plus address.
If it were “kremels+thing@kreme.com” then the net line out to say “finished match with result: ‘thing’” or some such.
It should not because I am not asking for the detail, I am only asking for :matches "*" -- "Are you pondering what I'm pondering?" "Well, I think so, Brain, but I can't memorize a whole opera in Yiddish."
On 22 Oct 2020, at 15:46, @lbutlr kremels@kreme.com wrote:
And it doesn't explain why "if address :matches ["To", "Cc"] ["*@*."] {" also failed to match despite also showing the email address.
“kremels@kreme.com” does not have a :detail part (https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples talks about this).
And I am not asking for :detail
OK, fair enough. I looked at that line many times for some reason. But the first point still stand.
-- For my birthday I got a humidifier and a de-humidifier... I put them in the same room and let them fight it out.
On Oct 22, 2020, at 15:58, @lbutlr kremels@kreme.com wrote:
On 22 Oct 2020, at 15:46, @lbutlr kremels@kreme.com wrote:
And it doesn't explain why "if address :matches ["To", "Cc"] ["*@*."] {" also failed to match despite also showing the email address.
“kremels@kreme.com” does not have a :detail part (https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples talks about this).
And I am not asking for :detail
OK, fair enough. I looked at that line many times for some reason. But the first point still stand.
Does you To or CC address end with a .?
One problem I had with :matches (if I recall correctly, I can’t find where I ran into this) is that :matches has an implicit “^” and “$” wrapped around what you’re looking for.
“some random string”
then trying to :match “random” won’t match that string. “*random*” *will* match (as will “some*” and “*string”).
Like I said, I’m not 100% sure, but I suspect if you add * to the end:
if address :matches ["To", "Cc"] ["*@*.*"] {
It might work.
Sean
On 22 Oct 2020, at 18:22, Sean Kamath kamath@moltingpenguin.com wrote:
On Oct 22, 2020, at 15:58, @lbutlr kremels@kreme.com wrote:
On 22 Oct 2020, at 15:46, @lbutlr kremels@kreme.com wrote:
And it doesn't explain why "if address :matches ["To", "Cc"] ["*@*."] {" also failed to match despite also showing the email address.
“kremels@kreme.com” does not have a :detail part (https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples talks about this).
And I am not asking for :detail
OK, fair enough. I looked at that line many times for some reason. But the first point still stand.
Does you To or CC address end with a .?
No, what I am trying to get is "user" and "example" in "user@example.com"
One problem I had with :matches (if I recall correctly, I can’t find where I ran into this) is that :matches has an implicit “^” and “$” wrapped around what you’re looking for.
That would break many things, but I will look into it. What I have done for now and is working is a much more complicated process where I am manually removing the '@' myself:
require ["copy", "variables", "envelope", "fileinto", "subaddress"];
if not envelope :matches "to" "backup" { if envelope :matches "to" "*" { set :lower "name" "${1}"; if string :matches "${name}" "*@*" { set "email" "${1}_${2}"; } # Only replaces one '.' But that's OK at this point. if string :matches "${email}" "*.*" { set "name" "${1}_${2}"; } set "backup" "backup+296.${name}@..."; redirect :copy "${backup}"; } else { redirect :copy "backup+296@..."; } }
This properly redirects a copy of the message to, for example, backup+296.kremels_kreme_com@...
If all goes well, the 'else' will never trigger.
I will try your suggestion if the implicit ^$.
Like I said, I’m not 100% sure, but I suspect if you add * to the end:
if address :matches ["To", "Cc"] ["*@*.*"] {
Thanks for the advice, I will definitely give that a go,
-- Mister Teatime had a truly brilliant mind, but it was brilliant like a fractured mirror, all marvelous facets and rainbows but, ultimately, also something that was broken. --Hogfather
On 23 Oct 2020, at 05:20, @lbutlr kremels@kreme.com wrote:
Like I said, I’m not 100% sure, but I suspect if you add * to the end:
if address :matches ["To", "Cc"] ["*@*.*"] {
Thanks for the advice, I will definitely give that a go,
Excellent! That was the secret sauce!
Thank you!
-- Hard work pays off in the future. Laziness pays off now.
On 23 Oct 2020, at 05:47, @lbutlr kremels@kreme.com wrote:
Excellent! That was the secret sauce!
Thank you!
For the sake of completeness, this is what I have ended up with:
#v+ require ["copy", "variables", "envelope", "fileinto", "subaddress"]; # :matches has implicit ^ and $ around the match if not envelope :matches "to" "*backup*" { # get the top level after @ (example.com => example) if envelope :matches "to" "*@*.*" { set :lower "domn" "${2}"; } # get the user without detail (foo+bar => foo) if envelope :user :matches "to" "*" { set :lower "user" "${1}"; } # Un-needed step, but shows what is done in the trace log set "backup" "backup+297.${domn}.${user}@*somedomain*"; redirect :copy "${backup}"; } #v-
(I don't think I need fileinto)
This means that mail for user@domain.tld and user+foo@domain.tld ends up in a mailbox, today, of
backup/Maildir/.297.domain.user/
And user2@domain.tld
backup/Maildir/.297.domain.user2/
(Which means the backup IMAP hierarchy is all sorted DOY=>domain=>user)
I'd like a fail condition if the redirect for some reason cannot send, but that's a project for tomorrow.
-- and I swear it happened just like this: / a sigh, a cry, a hungry kiss, the Gates of Love they budged an inch / I can't say much has happened since / but CLOSING TIME
On Oct 23, 2020, at 04:20, @lbutlr kremels@kreme.com wrote:
Does you To or CC address end with a .?
No, what I am trying to get is "user" and "example" in "user@example.com mailto:user@example.com"
The question was meant to elucidate that the ‘match’ string ended with a ‘.’. I understand what you’re trying to do.
That would break many things, but I will look into it. What I have done for now and is working is a much more complicated process where I am manually removing the '@' myself:
Perhaps (I am not sure if pigeonhole has it) the regex extension would be helpful: https://tools.ietf.org/id/draft-ietf-sieve-regex-01.html https://tools.ietf.org/id/draft-ietf-sieve-regex-01.html
if address :matches ["To", "Cc"] ["*@*.*"] {
Thanks for the advice, I will definitely give that a go,
I’m unclear if the match line I supposed would set 1, 2 and 3, and you can ignore 3.
Sean
participants (4)
-
unknown@example.com
-
@lbutlr
-
PGNet Dev
-
Sean Kamath