Commit 12f56edd 12f56edd0266292a4b55f45211c225a360b1188b by Sam Roberts

Commiting my example/test sieve scripts so I can maintain them with cvs

(I use them at work and home).
1 parent c1b88956
1 From coyote@desert.example.org Sun May 6 22:16:47 2001
2 From: coyote@desert.example.org
3 To: roadrunner@acme.example.com
4 Subject: I have a present for you
5 X-Caffeine: C8H10N4O2
6
7 Look, I'm sorry about the whole anvil thing, and I really
8 didn't mean to try and drop it on you from the top of the
9 cliff. I want to try to make it up to you. I've got some
10 great birdseed over here at my place--top of the line
11 stuff--and if you come by, I'll have it all wrapped up
12 for you. I'm really sorry for all the problems I've caused
13 for you over the years, but I know we can work this out.
14
15 --
16 Wile E. Coyote "Super Genius" coyote@desert.example.org
17
18 From b1ff@de.res.example.com Sun May 6 22:17:15 2001
19 From: youcouldberich!@reply-by-postal-mail.invalid
20 To: rube@landru.example.edu
21 Subject: $$$ YOU, TOO, CAN BE A MILLIONAIRE! $$$
22 Date: TBD
23
24 YOU MAY HAVE ALREADY WON TEN MILLION DOLLARS, BUT I DOUBT
25 IT! SO JUST POST THIS TO SIX HUNDRED NEWSGROUPS! IT WILL
26 GUARANTEE THAT YOU GET AT LEAST FIVE RESPONSES WITH MONEY!
27 MONEY! MONEY! COLD HARD CASH! YOU WILL RECEIVE OVER
28 $20,000 IN LESS THAN TWO MONTHS! AND IT'S LEGAL!!!!!!!!!
29 !!!!!!!!!!!!!!!!!!111111111!!!!!!!11111111111!!1 JUST
30 SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW!
31
32
1 # cmu-sieve/sv/Makefile
2
3 test: INBOX
4 ./Test 2>&1 | tee test.out
5
6 .PHONY: INBOX
7 INBOX:
8 cp INBOX.orig INBOX
9
10 t-%: t-%.sv INBOX ../sieve
11 ../sieve -vvv -f INBOX $<
12
13 .PHONY: ../sieve
14 ../sieve:
15 make -C .. sieve
16
1 if size :under 500K {
2 discard;
3 }
4
5 keep;
1 if size :over 550 { # this is a comment
2 discard;
3 }
1 require "fileinto";
2
3 if anyof (
4 not exists ["From", "Date"],
5 header :contains "from" "fool@example.edu"
6 )
7 {
8 discard;
9 }
10 if header :contains "from" "coyote"
11 {
12 fileinto "popbox"; # "pop://sam:passwed@fw";
13 }
1 if header :contains :comparator "i;octet" "Subject"
2 "MAKE MONEY FAST" {
3 discard;
4 }
5
1 require "fileinto";
2 if header :contains "from" "coyote" {
3 discard;
4 } elsif header :contains ["subject"] ["$$$"] {
5 discard;
6 } else {
7 fileinto "INBOX";
8 }
1 if header :contains ["From"] ["coyote"] {
2 redirect "acm@example.edu";
3 } elsif header :contains "Subject" "$$$" {
4 redirect "postmaster@example.edu";
5 } else {
6 redirect "field@example.edu";
7 }
1 require ["fileinto", "reject"];
2 require "fileinto";
3 # require "vacation";
4
1 require "reject";
2
3 if header :contains "from" "coyote@desert.example.org" {
4 reject
5 "I am not taking mail from you, and I don't want
6 your birdseed, either!";
7 }
8
1 require "fileinto";
2 if header :contains ["from"] "coyote" {
3 fileinto "INBOX.harassment";
4 }
5
1 if size :under 1M { keep; } else { discard; }
2
1
2 if not size :under 1M { discard; }
3
1 if header :contains ["from"] ["idiot@example.edu"] {
2 discard;
3 }
1 if address :is :all "from" "tim@example.com" {
2 discard;
3 }
4
1 # header :is ["X-Caffeine"] [""] => false
2 # header :contains ["X-Caffeine"] [""] => true
3
4 # These should be true, then, and not affect the test mbox.
5
6 if header :is ["X-Caffeine"] [""] {
7 discard;
8 }
9
10 if not header :contains ["X-Caffeine"] [""] {
11 discard;
12 }
13
1 #
2 # Example Sieve Filter
3 # Declare any optional features or extension used by the script
4 #
5 require ["fileinto", "reject"];
6
7 #
8 # Reject any large messages (note that the four leading dots get
9 # "stuffed" to three)
10 #
11 if size :over 1M
12 {
13 reject text:
14 Please do not send me large attachments.
15 Put your file on a server and send me the URL.
16 Thank you.
17 .... Fred
18 .
19 ;
20 stop;
21 }
22 #
23 # Handle messages from known mailing lists
24 # Move messages from IETF filter discussion list to filter folder
25 #
26 if header :is "Sender" "owner-ietf-mta-filters@imc.org"
27 {
28 fileinto "filter"; # move to "filter" folder
29 }
30 #
31 # Keep all messages to or from people in my company
32 #
33 elsif address :domain :is ["From", "To"] "example.com"
34 {
35 keep; # keep in "In" folder
36 }
37
38 #
39 # Try and catch unsolicited email. If a message is not to me,
40 # or it contains a subject known to be spam, file it away.
41 #
42 elsif anyof (
43 not address :all :contains
44 ["To", "Cc", "Bcc"] "me@example.com",
45 header :matches
46 "subject" ["*make*money*fast*", "*university*dipl*mas*"]
47 )
48 {
49 # If message header does not contain my address,
50 # it's from a list.
51 fileinto "spam"; # move to "spam" folder
52 }
53 else
54 {
55 # Move all other (non-company) mail to "personal"
56 # folder.
57 fileinto "personal";
58 }
59
1 # an empty script
2
1
2 require "fileinto";
3
4 fileinto "./_save-all.mbox";
5
1 # Example sieve script.
2
3 require "fileinto";
4
5 if size :over 20 {
6 fileinto "/home/sam/p/gnu/mailutils/cmu-sieve/sv/inbox";
7 }
8
9 if address :domain :is "to" "uwaterloo.ca" {
10 redirect "dom@is.uw";
11 }
12
13 if header :is "Status" "RO" {
14 redirect "status@is.ro";
15 }
16
17 keep;
18
1 if size :over 100K { /* this is a comment
2 this is still a comment */ discard /* this is a comment
3 */ ;
4 }
1 require "envelope";
2
3 if envelope :all :is "from" "tim@example.com" {
4 discard;
5 }
1 require "fileinto";
2
3 if exists "subject"
4 {
5 fileinto "subject";
6 }
7
1 require "fileinto";
2
3 if allof(
4 size :over 10 ,
5 exists "x-caffeine"
6 )
7 {
8 fileinto "jetfuel";
9 }
10 else
11 {
12 fileinto "decaf";
13 }
14
1 require "fileinto";
2
3 if header :contains ["to", "cc"] "bug-mailutils@gnu.org"
4 {
5 fileinto "+l.mailutils";
6 }
7