1
.\" <!-- $Id: maildropex.sgml,v 1.5 2004/07/27 01:36:41 mrsam Exp $ -->
2
.\" <!-- Copyright 1998 - 2001 Double Precision, Inc. See COPYING for -->
3
.\" <!-- distribution information. -->
4
.\" This manpage has been automatically generated by docbook2man
5
.\" from a DocBook document. This tool can be found at:
6
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
7
.\" Please send any bug reports, improvements, comments, patches,
8
.\" etc. to Steve Cheng <steve@ggi-project.org>.
9
.TH "MAILDROPEX" "7" "27 August 2004" "Double Precision, Inc." ""
12
maildropex \- maildrop filtering language examples
16
\fI$HOME/.mailfilter\fR,
17
\fI$HOME/.mailfilters/*\fR
20
If \fI$HOME/.mailfilter\fR exists, filtering instructions in
21
this file will be carried out prior to delivering the message. The filtering
23
instruct \fBmaildrop\fR to discard the message, save the
25
different mailbox, or forward the message to another address. If
26
\fI$HOME/.mailfilter\fR does not exist,
27
or does not provide explicit delivery
28
instructions, \fBmaildrop\fR delivers the message to the
29
user's system mailbox.
31
The files in \fI$HOME/.mailfilters\fR
32
are used when \fBmaildrop\fR is
33
invoked in embedded mode.
36
Take all mail that's sent to the 'auto' mailing list, and save it in
37
\fIMail/auto\fR\&. The 'auto' mailing list software adds a
38
"Delivered-To: auto@domain.com" header to all messages:
44
if (/^Delivered-To: *auto@domain\\.com$/)
48
After the \fBto\fR command delivers the message,
49
\fBmaildrop\fR automatically
50
stops filtering and terminates without executing the subsequent instructions
54
Take all mail from <boss@domain.com> about the current project
55
status, save it in \fIMail/project\fR, then forward a copy to
62
if (/^From: *boss@domain\\.com/ \\
63
&& /^Subject:.*[:wbreak:]project status[:wbreak:]/)
70
Note that it is necessary to use a backslash in order to continue the
71
\fBif\fR statement on the next line.
73
Keep copies of the last 50 messages that you received in the
75
directory 'backup'. NOTE: 'backup' must be a \fImaildir\fR
77
mailbox. You can create a \fImaildir\fR using the
86
`cd backup/new && rm -f dummy \\`ls -t | sed -e 1,50d\\``
89
Put this at the beginning of your filter file, before any other filtering
90
instructions. This is a good idea to have when you are learning
91
\fBmaildrop\fR\&. If you make a mistake and accidentally delete a
93
can recover it from the backup/new subdirectory.
95
Save messages that are at least 100 lines long (approximately) into
107
Send messages from the auto mailing list to the program 'archive', using a
108
lock file to make sure that only one instance of the archive program will be
109
running at the same time:
115
if (/^Delivered-To: *auto@domain\\.com$/)
116
dotlock "auto.lock" {
123
Check if the Message-ID: header in the message is identical
125
that was recently seen. Discard the message if it is, otherwise continue to
132
`reformail -D 8000 duplicate.cache`
133
if ( $RETURNCODE == 0 )
137
The reformail command maintains a list of
138
recently seen Message-IDs in the file
139
\fIduplicate.cache\fR\&.
141
Here's a more complicated example. This fragment is intended to go right
142
after the message has been filtered according to your regular rules, and just
143
before the message should be saved in your mailbox:
150
xfilter "reformail -r -t"
152
getaddr($MATCH) =~ /^.*/;
154
MATCH=tolower($MATCH)
155
flock "vacation.lock" {
156
`fgrep -iqx "$MATCH" vacation.lst 2>/dev/null || { \\
157
echo "$MATCH" >>vacation.lst ; \\
161
if ( $RETURNCODE == 0 )
163
to "| ( cat - ; echo ''; cat vacation.msg) | $SENDMAIL"
167
This code maintains a list of everyone who sent you mail in the file called
168
\fIvacation.lst\fR\&.
169
When a message is received from anyone that is not already on
170
the list, the address is added to the list, and the contents of the file
171
\fIvacation.msg\fR are mailed back to the sender.
172
This is intended to reply notify
173
people that you will not be answering mail for a short period of time.
175
The first statement saves the original message in your regular mailbox.
178
is used to generate an
179
autoreply header to the sender. The To: header in the
180
autoreply - which was
181
the sender of the original message - is extracted, and the \fBgetaddr\fR
182
function is used to strip the
183
person's name, leaving the address only. The file
184
\fIvacation.lst\fR is checked,
185
using a lock file to guarantee atomic access and update (overkill, probably).
186
Note that the backslashes are required.
188
If the address is already in the file, \fBmaildrop\fR exits,
190
contents of \fIvacation.msg\fR are appended to the autoreply
191
header, and mailed out.
193
Here's a version of the vacation script that uses a GDBM database file
194
instead. The difference between this script and the previous script is that
195
the previous script will send a vacation message to a given E-mail address
196
only once. The following script will store the time that the vacation message
197
was sent in the GDBM file. If it's been at least a week since the vacation
198
message has been sent to the given address, another vacation message will be
201
Even though a GDBM database file is used, locking is still necessary
202
because the GDBM library does not allow more than one process to open the same
203
database file for writing:
210
xfilter "reformail -r -t"
212
getaddr($MATCH) =~ /^.*/;
213
MATCH=tolower($MATCH)
214
flock "vacation.lock" {
216
if (gdbmopen("vacation.dat", "C") == 0)
218
if ( (prev_time=gdbmfetch($MATCH)) ne "" && \\
219
$prev_time >= $current_time - 60 * 60 * 24 * 7)
223
gdbmstore($MATCH, $current_time)
227
to "| ( cat - ; echo ''; cat vacation.msg) | $SENDMAIL"
231
This script requires that \fBmaildrop\fR must be compiled with
233
support enabled, which is done by default if GDBM libraries are present.
235
After you return from vacation, you can use a simple Perl script to obtain
236
a list of everyone who sent you mail (of course, that can also be determined
237
by examining your mailbox).
241
\fBmaildropfilter\fR(7),