-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlabeller.script.example
78 lines (63 loc) · 1.59 KB
/
labeller.script.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// This is the example-script which adds labels to new/unread messages.
//
// Save this file at ~/.labeller.script, or pass the path to the
// CLI via:
//
// $ labeller -script /path/to/script
//
//
// Assuming we get a message from "[email protected]" we'll add
// two labels "bob" and "example.com"
//
// Messages can have multiple recipients, but will only have a single
// sender, of course.
//
add( FromPart );
add( FromDomain );
//
// Prove we can do "complex" things too - by adding a label
// conditionally, depending upon the contents of the Subject-header.
//
// This also marks the message as having been read.
//
if ( Subject ~= /attic: backup/ ) {
//
// Add the backup-label
//
add( "backups" );
//
// Mark the message as having been read.
//
remove( "UNREAD" );
}
//
// As noted messages can have multiple recipients.
//
// Output the count and distinct recipients here.
//
print( "\tThe message has ", len(To), " recipients\n");
foreach index,recipient in To {
printf("Recipient %d - LocalPart:%s Domain:%s\n",
index, ToPart[index], ToDomain[index])
}
print( "\n");
//
// Testing recipients is easier since we can use the `in` function
// to test if a value is in the array. No need to walk over it manually.
//
if ( "[email protected]" in To ) {
print( "I'm a Debian mail\n");
}
//
// Show existing labels, if any
//
print("\tThe message has ", len(Labels), " labels.\n");
foreach index,label in Labels {
printf("\tLabel %d is %s\n", index, label);
}
//
// Return value doesn't matter for this script, but you MUST
// return something.
//
return false;