Dovecot/Sieve shortcuts?
Hi,
Is there a clean way to match on an email address the way procmail ^TO_ did? that was a macro which expanded to (^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope |Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)
so you could write
- ^TO_dovecot dovecot
and grab messages to the list. In sieve, I find myseld writing ["To","cc"] and wonder if there's a better way.
Adam
Am 9. Mai 2017 17:47:13 MESZ schrieb Adam Shostack <adam@shostack.org>:
Hi,
Is there a clean way to match on an email address the way procmail ^TO_ did? that was a macro which expanded to (^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope |Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)
so you could write
- ^TO_dovecot dovecot
and grab messages to the list. In sieve, I find myseld writing ["To","cc"] and wonder if there's a better way. You could use the X-BeenThere or List-Id headers to match mailing list traffic
-- Christian Kivalo
Adam
-- Christian Kivalo
On 5/9/17, 11:25 AM, "dovecot on behalf of Christian Kivalo" <dovecot-bounces@dovecot.org on behalf of ml+dovecot@valo.at> wrote:
Am 9. Mai 2017 17:47:13 MESZ schrieb Adam Shostack <adam@shostack.org>:
>Hi,
>
>Is there a clean way to match on an email address the way procmail
>^TO_ did? that was a macro which expanded to
>(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope
>|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)
>
>so you could write
>* ^TO_dovecot
>dovecot
>
>and grab messages to the list. In sieve, I find myseld writing
>["To","cc"] and wonder if there's a better way.
You could use the X-BeenThere or List-Id headers to match mailing list traffic
--
Christian Kivalo
>
>Adam
I’ve been using:
if header :contains ["List-Id","Mailing-List", "Sender","X-List-Name","List-Post"] ["<mailto:php-general@lists.php.net>"] { fileinto "lists/php/general"; stop; }
For all my mailing list traffic. That seems(!) to catch most of them.
On Tue, May 09, 2017 at 11:27:22AM -0500, Larry Rosenman wrote: | On 5/9/17, 11:25 AM, "dovecot on behalf of Christian Kivalo" <dovecot-bounces@dovecot.org on behalf of ml+dovecot@valo.at> wrote:
| Am 9. Mai 2017 17:47:13 MESZ schrieb Adam Shostack <adam@shostack.org>:
| >Hi,
| >
| >Is there a clean way to match on an email address the way procmail
| >^TO_ did? that was a macro which expanded to
| >(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope
| >|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)
| >
| >so you could write
| >* ^TO_dovecot
| >dovecot
| >
| >and grab messages to the list. In sieve, I find myseld writing
| >["To","cc"] and wonder if there's a better way.
| You could use the X-BeenThere or List-Id headers to match mailing list traffic
|
| --
| Christian Kivalo
| >
| >Adam
|
| I’ve been using:
|
| if header :contains ["List-Id","Mailing-List",
| "Sender","X-List-Name","List-Post"]
| ["<mailto:php-general@lists.php.net>"]
| {
| fileinto "lists/php/general";
| stop;
| }
|
| For all my mailing list traffic. That seems(!) to catch most of them.
Thanks! Is there anything shorter, or a macro capability? I ask because I manually maintain the file, and really this
if address :is :localpart ["to", "cc"] "csprs" {fileinto :create "csprs"; stop;}
is easier for me to read and edit than that.
Adam
On 5/9/17, 12:38 PM, "Adam Shostack" <adam@shostack.org> wrote:
On Tue, May 09, 2017 at 11:27:22AM -0500, Larry Rosenman wrote:
| On 5/9/17, 11:25 AM, "dovecot on behalf of Christian Kivalo" <dovecot-bounces@dovecot.org on behalf of ml+dovecot@valo.at> wrote:
| Am 9. Mai 2017 17:47:13 MESZ schrieb Adam Shostack <adam@shostack.org>:
| >Hi,
| >
| >Is there a clean way to match on an email address the way procmail
| >^TO_ did? that was a macro which expanded to
| >(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope
| >|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)
| >
| >so you could write
| >* ^TO_dovecot
| >dovecot
| >
| >and grab messages to the list. In sieve, I find myseld writing
| >["To","cc"] and wonder if there's a better way.
| You could use the X-BeenThere or List-Id headers to match mailing list traffic
|
| --
| Christian Kivalo
| >
| >Adam
|
| I’ve been using:
|
| if header :contains ["List-Id","Mailing-List",
| "Sender","X-List-Name","List-Post"]
| ["<mailto:php-general@lists.php.net>"]
| {
| fileinto "lists/php/general";
| stop;
| }
|
| For all my mailing list traffic. That seems(!) to catch most of them.
Thanks! Is there anything shorter, or a macro capability? I ask
because I manually maintain the file, and really this
if address :is :localpart ["to", "cc"] "csprs" {fileinto :create "csprs"; stop;}
is easier for me to read and edit than that.
Adam
I haven’t found one. You might(!) be able to use a script or something to generate it.
I just keep repeating the block of code.
Yes, it can be on one line, but I like readability (
-- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 214-642-9640 E-Mail: larryrtx@gmail.com US Mail: 17716 Limpia Crk, Round Rock, TX 78664-7281
On Tue, May 09, 2017 at 12:41:10PM -0500, Larry Rosenman wrote:
| | >^TO_ did? that was a macro which expanded to
| | >(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope
| | >|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)
| | >
| | >so you could write
| | >* ^TO_dovecot
| | >dovecot
| | >
| | >and grab messages to the list. In sieve, I find myseld writing
| | >["To","cc"] and wonder if there's a better way.
| | You could use the X-BeenThere or List-Id headers to match mailing list traffic
| |
| | --
| | Christian Kivalo
| | >
| | >Adam
| |
| | I’ve been using:
| |
| | if header :contains ["List-Id","Mailing-List",
| | "Sender","X-List-Name","List-Post"]
| | ["<mailto:php-general@lists.php.net>"]
| | {
| | fileinto "lists/php/general";
| | stop;
| | }
| |
| | For all my mailing list traffic. That seems(!) to catch most of them.
|
| Thanks! Is there anything shorter, or a macro capability? I ask
| because I manually maintain the file, and really this
|
| if address :is :localpart ["to", "cc"] "csprs" {fileinto :create "csprs"; stop;}
|
| is easier for me to read and edit than that.
|
|
| Adam
|
| I haven’t found one. You might(!) be able to use a script or something to generate it.
|
| I just keep repeating the block of code.
|
| Yes, it can be on one line, but I like readability (
mmmm, sed 's/PROC_TO/(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope>|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)/g' readable > .dovecot.sieve && sievec .dovecot.sieve
:)
On Tue, May 09, 2017 at 11:27:22AM -0500, Larry Rosenman wrote:
On 5/9/17, 11:25 AM, "dovecot on behalf of Christian Kivalo" <dovecot-bounces@dovecot.org on behalf of ml+dovecot@valo.at> wrote:
Am 9. Mai 2017 17:47:13 MESZ schrieb Adam Shostack <adam@shostack.org>:
Hi,
Is there a clean way to match on an email address the way procmail ^TO_ did? that was a macro which expanded to (^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope |Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)
so you could write
- ^TO_dovecot dovecot
and grab messages to the list. In sieve, I find myseld writing ["To","cc"] and wonder if there's a better way. You could use the X-BeenThere or List-Id headers to match mailing list traffic
-- Christian Kivalo
Adam
I’ve been using:
if header :contains ["List-Id","Mailing-List", "Sender","X-List-Name","List-Post"] ["<mailto:php-general@lists.php.net>"] { fileinto "lists/php/general"; stop; }
For all my mailing list traffic. That seems(!) to catch most of them.
I can't remember where I got the original algorithm (and, in particular, the ordering) from, but I've been using the attached sieve script for a while with numerous mailinglists. It uses the 'regex' module to parse the mailing-list name from the headers (with various attempts to handle most of the major mailing-list applications). The listname is lower-cased (for consistency) and the message is filed into that folder (creating the folder if necessary). This means that, when I sign up for a new mailing-list, messages just start appearing in their own folder.
-- For more information, please reread.
Thanks! This is super-interesting.
As I try to set up include, I get failures which may indicate a need for more coffee, but in /etc/dovecot/cond.f/90-sieve.conf I have:
plugin { # Directory for :personal include scripts. The default is to use home directory. sieve_dir = %h/.sieve
# Directory for :global include scripts (not to be confused with sieve_global_path). # If unset, the include fails. sieve_global_dir = /etc/dovecot/sieve/ }
In .sieve/mailinglist.sieve I have your file.
In my main .dovecot, I have a line
include :personal "mailinglist";
When I run sievec, I see: sievec(adam): Debug: Effective uid=1000, gid=1000, home=/home/adam .dovecot: line 181: error: included personal script 'mailinglist' does not exist. .dovecot: error: validation failed. sievec(adam): Error: failed to compile sieve script '.dovecot.sieve'
I've tried include "mailinglist" and "mailinglist.sieve"; I've tried it in ~ and the .sieve directory.
All this follows https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples, with the exception that I'm using .sieve rather than sieve as the directory name.
Can someone point out where I'm failing?
Adam
On Wed, May 10, 2017 at 10:50:23AM +0100, Darac Marjal wrote: | On Tue, May 09, 2017 at 11:27:22AM -0500, Larry Rosenman wrote: | >On 5/9/17, 11:25 AM, "dovecot on behalf of Christian Kivalo" <dovecot-bounces@dovecot.org on behalf of ml+dovecot@valo.at> wrote: | > | > | > | > Am 9. Mai 2017 17:47:13 MESZ schrieb Adam Shostack <adam@shostack.org>: | > >Hi, | > > | > >Is there a clean way to match on an email address the way procmail | > >^TO_ did? that was a macro which expanded to | > >(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope | > >|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?) | > > | > >so you could write | > >* ^TO_dovecot | > >dovecot | > > | > >and grab messages to the list. In sieve, I find myseld writing | > >["To","cc"] and wonder if there's a better way. | > You could use the X-BeenThere or List-Id headers to match mailing list traffic | > | > -- | > Christian Kivalo | > > | > >Adam | > | >I’ve been using: | > | >if header :contains ["List-Id","Mailing-List", | > "Sender","X-List-Name","List-Post"] | > ["<mailto:php-general@lists.php.net>"] | >{ | > fileinto "lists/php/general"; | > stop; | >} | > | >For all my mailing list traffic. That seems(!) to catch most of them. | | I can't remember where I got the original algorithm (and, in particular, | the ordering) from, but I've been using the attached sieve script for a | while with numerous mailinglists. It uses the 'regex' module to parse | the mailing-list name from the headers (with various attempts to handle | most of the major mailing-list applications). The listname is | lower-cased (for consistency) and the message is filed into that folder (creating the folder if necessary). This means that, when I sign up for a new mailing-list, messages just start appearing in their own folder. | | -- | For more information, please reread.
This took about 30 minutes of debugging so I figured I'd share.
The list-id block was giving me false positives, so I changed a keep to a fileinto :create, as shown below.
Adam
# Mailman & other lists using list-id elsif exists "list-id" { if header :regex "list-id" "<([a-z_0-9-]+)[.@]" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { if header :regex "list-id" "^\\s*<?([a-z_0-9-]+)[.@]" { set :lower "listname" "${1}"; fileinto :create "${listname}"; stop; } else { # keep; fileinto :create "bulk"; stop;
}
}
stop;}
On Wed, May 10, 2017 at 05:02:27PM +0000, Adam Shostack wrote: | Thanks! This is super-interesting. | | As I try to set up include, I get failures which may indicate a need | for more coffee, but in /etc/dovecot/cond.f/90-sieve.conf I have: | | plugin { | # Directory for :personal include scripts. The default is to use | home directory. | sieve_dir = %h/.sieve | | # Directory for :global include scripts (not to be confused with | sieve_global_path). | # If unset, the include fails. | sieve_global_dir = /etc/dovecot/sieve/ | } | | In .sieve/mailinglist.sieve I have your file. | | In my main .dovecot, I have a line | | include :personal "mailinglist"; | | When I run sievec, I see: | sievec(adam): Debug: Effective uid=1000, gid=1000, home=/home/adam | .dovecot: line 181: error: included personal script | 'mailinglist' does not exist. | .dovecot: error: validation failed. | sievec(adam): Error: failed to compile sieve script '.dovecot.sieve' | | I've tried include "mailinglist" and "mailinglist.sieve"; I've tried | it in ~ and the .sieve directory. | | All this follows https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples, | with the exception that I'm using .sieve rather than sieve as the | directory name. | | Can someone point out where I'm failing? | | Adam | | | On Wed, May 10, 2017 at 10:50:23AM +0100, Darac Marjal wrote: | | On Tue, May 09, 2017 at 11:27:22AM -0500, Larry Rosenman wrote: | | >On 5/9/17, 11:25 AM, "dovecot on behalf of Christian Kivalo" <dovecot-bounces@dovecot.org on behalf of ml+dovecot@valo.at> wrote: | | > | | > | | > | | > Am 9. Mai 2017 17:47:13 MESZ schrieb Adam Shostack <adam@shostack.org>: | | > >Hi, | | > > | | > >Is there a clean way to match on an email address the way procmail | | > >^TO_ did? that was a macro which expanded to | | > >(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope | | > >|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?) | | > > | | > >so you could write | | > >* ^TO_dovecot | | > >dovecot | | > > | | > >and grab messages to the list. In sieve, I find myseld writing | | > >["To","cc"] and wonder if there's a better way. | | > You could use the X-BeenThere or List-Id headers to match mailing list traffic | | > | | > -- | | > Christian Kivalo | | > > | | > >Adam | | > | | >I’ve been using: | | > | | >if header :contains ["List-Id","Mailing-List", | | > "Sender","X-List-Name","List-Post"] | | > ["<mailto:php-general@lists.php.net>"] | | >{ | | > fileinto "lists/php/general"; | | > stop; | | >} | | > | | >For all my mailing list traffic. That seems(!) to catch most of them. | | | | I can't remember where I got the original algorithm (and, in particular, | | the ordering) from, but I've been using the attached sieve script for a | | while with numerous mailinglists. It uses the 'regex' module to parse | | the mailing-list name from the headers (with various attempts to handle | | most of the major mailing-list applications). The listname is | | lower-cased (for consistency) and the message is filed into that folder (creating the folder if necessary). This means that, when I sign up for a new mailing-list, messages just start appearing in their own folder. | | | | -- | | For more information, please reread. | | | |
participants (4)
-
Adam Shostack
-
Christian Kivalo
-
Darac Marjal
-
Larry Rosenman