Debian Codegraph @

upstream/debian-trixie/man7/maildropex.7

raw
1 '\" t
2 .\"<!-- Copyright 1998 - 2010 Double Precision, Inc. See COPYING for -->
3 .\"<!-- distribution information. -->
4 .\" Title: maildropex
5 .\" Author: Sam Varshavchik
6 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Date: 11/04/2020
8 .\" Manual: Double Precision, Inc.
9 .\" Source: Courier Mail Server
10 .\" Language: English
11 .\"
12 .TH "MAILDROPEX" "7" "11/04/2020" "Courier Mail Server" "Double Precision, Inc\&."
13 .\" -----------------------------------------------------------------
14 .\" * Define some portability stuff
15 .\" -----------------------------------------------------------------
16 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 .\" http://bugs.debian.org/507673
18 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
19 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .ie \n(.g .ds Aq \(aq
21 .el .ds Aq '
22 .\" -----------------------------------------------------------------
23 .\" * set default formatting
24 .\" -----------------------------------------------------------------
25 .\" disable hyphenation
26 .nh
27 .\" disable justification (adjust text to left margin only)
28 .ad l
29 .\" -----------------------------------------------------------------
30 .\" * MAIN CONTENT STARTS HERE *
31 .\" -----------------------------------------------------------------
32 .SH "NAME"
33 maildropex \- maildrop filtering language examples
34 .SH "SYNOPSIS"
35 .sp
36 $HOME/\&.mailfilter, $HOME/\&.mailfilters/*
37 .SH "DESCRIPTION"
38 .PP
39 If
40 $HOME/\&.mailfilter
41 exists, filtering instructions in this file will be carried out prior to delivering the message\&. The filtering instructions may instruct
42 \fBmaildrop\fR
43 to discard the message, save the message in a different mailbox, or forward the message to another address\&. If
44 $HOME/\&.mailfilter
45 does not exist, or does not provide explicit delivery instructions,
46 \fBmaildrop\fR
47 delivers the message to the user\*(Aqs system mailbox\&.
48 .PP
49 The files in
50 $HOME/\&.mailfilters
51 are used when
52 \fBmaildrop\fR
53 is invoked in embedded mode\&.
54 .SH "EXAMPLES"
55 .PP
56 Take all mail that\*(Aqs sent to the \*(Aqauto\*(Aq mailing list, and save it in
57 Mail/auto\&. The \*(Aqauto\*(Aq mailing list software adds a "Delivered\-To: auto@domain\&.com" header to all messages:
58 .sp
59 .if n \{\
60 .RS 4
61 .\}
62 .nf
63 if (/^Delivered\-To: *auto@domain\e\&.com$/)
64 to Mail/auto
65 .fi
66 .if n \{\
67 .RE
68 .\}
69 .PP
70 After the
71 \fBto\fR
72 command delivers the message,
73 \fBmaildrop\fR
74 automatically stops filtering and terminates without executing the subsequent instructions in the
75 filter file\&.
76 .PP
77 Take all mail from
78 <boss@domain\&.com>
79 about the current project status, save it in
80 Mail/project, then forward a copy to John:
81 .sp
82 .if n \{\
83 .RS 4
84 .\}
85 .nf
86 if (/^From: *boss@domain\e\&.com/ \e
87 && /^Subject:\&.*[:wbreak:]project status[:wbreak:]/)
88 {
89 cc "!john"
90 to Mail/project
91 }
92 .fi
93 .if n \{\
94 .RE
95 .\}
96 .PP
97 Note that it is necessary to use a backslash in order to continue the
98 \fBif\fR
99 statement on the next line\&.
100 .PP
101 Keep copies of the last 50 messages that you received in the
102 maildir
103 directory \*(Aqbackup\*(Aq\&. NOTE: \*(Aqbackup\*(Aq must be a
104 maildir
105 directory, not a mailbox\&. You can create a
106 maildir
107 using the
108 \fBmaildirmake\fR
109 command\&.
110 .sp
111 .if n \{\
112 .RS 4
113 .\}
114 .nf
115 cc backup
116 `cd backup/new && rm \-f dummy \e`ls \-t | sed \-e 1,50d\e``
117 .fi
118 .if n \{\
119 .RE
120 .\}
121 .PP
122 Put this at the beginning of your filter file, before any other filtering instructions\&. This is a good idea to have when you are learning
123 \fBmaildrop\fR\&. If you make a mistake and accidentally delete a message, you can recover it from the backup/new subdirectory\&.
124 .PP
125 Save messages that are at least 100 lines long (approximately) into
126 Mail/IN\&.Large::
127 .sp
128 .if n \{\
129 .RS 4
130 .\}
131 .nf
132 if ( $LINES > 100 )
133 to Mail/IN\&.Large
134 .fi
135 .if n \{\
136 .RE
137 .\}
138 .PP
139 Send messages from the auto mailing list to the program \*(Aqarchive\*(Aq, using a lock file to make sure that only one instance of the archive program will be running at the same time:
140 .sp
141 .if n \{\
142 .RS 4
143 .\}
144 .nf
145 if (/^Delivered\-To: *auto@domain\e\&.com$/)
146 dotlock "auto\&.lock" {
147
148 to "|archive"
149 }
150 .fi
151 .if n \{\
152 .RE
153 .\}
154 .PP
155 Check if the
156 Message\-ID:
157 header in the message is identical to the same header that was recently seen\&. Discard the message if it is, otherwise continue to filter the message:
158 .sp
159 .if n \{\
160 .RS 4
161 .\}
162 .nf
163 `reformail \-D 8000 duplicate\&.cache`
164 if ( $RETURNCODE == 0 )
165 exit
166 .fi
167 .if n \{\
168 .RE
169 .\}
170 .PP
171 The
172 \m[blue]\fBreformail\fR\m[]\&\s-2\u[1]\d\s+2
173 command maintains a list of recently seen Message\-IDs in the file
174 duplicate\&.cache\&.
175 .if n \{\
176 .sp
177 .\}
178 .RS 4
179 .it 1 an-trap
180 .nr an-no-space-flag 1
181 .nr an-break-flag 1
182 .br
183 .ps +1
184 \fBNote\fR
185 .ps -1
186 .br
187 .PP
188 Unlike a similar feature in the
189 \fBformail\fR
190 command,
191 \m[blue]\fBreformail\fR\m[]\&\s-2\u[1]\d\s+2
192 takes care of locking the file, so it\*(Aqs not necessary to implement your own locking mechanism for this option\&.
193 .sp .5v
194 .RE
195 .PP
196 Here\*(Aqs a more complicated example\&. This fragment is intended to go right after the message has been filtered according to your regular rules, and just before the message should be saved in your mailbox:
197 .sp
198 .if n \{\
199 .RS 4
200 .\}
201 .nf
202 cc $DEFAULT
203 xfilter "reformail \-r \-t"
204 /^To:\&.*/
205 getaddr($MATCH) =~ /^\&.*/;
206
207 MATCH=tolower($MATCH)
208 flock "vacation\&.lock" {
209 `fgrep \-iqx "$MATCH" vacation\&.lst 2>/dev/null || { \e
210 echo "$MATCH" >>vacation\&.lst ; \e
211 exit 1 ; \e
212 } `
213 }
214 if ( $RETURNCODE == 0 )
215 exit
216 to "| ( cat \- ; echo \*(Aq\*(Aq; cat vacation\&.msg) | $SENDMAIL"
217 .fi
218 .if n \{\
219 .RE
220 .\}
221 .PP
222 This code maintains a list of everyone who sent you mail in the file called
223 vacation\&.lst\&. When a message is received from anyone that is not already on the list, the address is added to the list, and the contents of the file
224 vacation\&.msg
225 are mailed back to the sender\&. This is intended to reply notify people that you will not be answering mail for a short period of time\&.
226 .PP
227 The first statement saves the original message in your regular mailbox\&. Then,
228 \m[blue]\fB\fBxfilter\fR\fR\m[]\&\s-2\u[2]\d\s+2
229 is used to generate an autoreply header to the sender\&. The
230 To:
231 header in the autoreply \- which was the sender of the original message \- is extracted, and the
232 \m[blue]\fB\fBgetaddr\fR\fR\m[]\&\s-2\u[3]\d\s+2
233 function is used to strip the person\*(Aqs name, leaving the address only\&. The file
234 vacation\&.lst
235 is checked, using a lock file to guarantee atomic access and update (overkill, probably)\&. Note that the backslashes are required\&.
236 .PP
237 If the address is already in the file,
238 \fBmaildrop\fR
239 exits, otherwise the contents of
240 vacation\&.msg
241 are appended to the autoreply header, and mailed out\&.
242 .if n \{\
243 .sp
244 .\}
245 .RS 4
246 .it 1 an-trap
247 .nr an-no-space-flag 1
248 .nr an-break-flag 1
249 .br
250 .ps +1
251 \fBNote\fR
252 .ps -1
253 .br
254 .PP
255 An easier to make a vacation script is with
256 \m[blue]\fB\fBmailbot\fR(1)\fR\m[]\&\s-2\u[4]\d\s+2\&.
257 .sp .5v
258 .RE
259 .PP
260 Here\*(Aqs a version of the vacation script that uses a GDBM database file instead\&. The difference between this script and the previous script is that the previous script will send a vacation message to a given E\-mail address only once\&. The following script will store the time that the vacation message was sent in the GDBM file\&. If it\*(Aqs been at least a week since the vacation message has been sent to the given address, another vacation message will be sent\&.
261 .PP
262 Even though a GDBM database file is used, locking is still necessary because the GDBM library does not allow more than one process to open the same database file for writing:
263 .sp
264 .if n \{\
265 .RS 4
266 .\}
267 .nf
268 cc $DEFAULT
269 xfilter "reformail \-r \-t"
270 /^To:\&.*/
271 getaddr($MATCH) =~ /^\&.*/;
272 MATCH=tolower($MATCH)
273 flock "vacation\&.lock" {
274 current_time=time;
275 if (gdbmopen("vacation\&.dat", "C") == 0)
276 {
277 if ( (prev_time=gdbmfetch($MATCH)) ne "" && \e
278 $prev_time >= $current_time \- 60 * 60 * 24 * 7)
279 {
280 exit
281 }
282 gdbmstore($MATCH, $current_time)
283 gdbmclose
284 }
285 }
286 to "| ( cat \- ; echo \*(Aq\*(Aq; cat vacation\&.msg) | $SENDMAIL"
287 .fi
288 .if n \{\
289 .RE
290 .\}
291 .PP
292 This script requires that
293 \fBmaildrop\fR
294 must be compiled with GDBM support enabled, which is done by default if GDBM libraries are present\&.
295 .PP
296 After you return from vacation, you can use a simple Perl script to obtain a list of everyone who sent you mail (of course, that can also be determined by examining your mailbox)\&.
297 .SH "SEE ALSO"
298 .PP
299 \m[blue]\fB\fBmaildrop\fR(1)\fR\m[]\&\s-2\u[5]\d\s+2,
300 \m[blue]\fB\fBmaildropfilter\fR(7)\fR\m[]\&\s-2\u[6]\d\s+2,
301 \m[blue]\fB\fBreformail\fR(1)\fR\m[]\&\s-2\u[1]\d\s+2,
302 \m[blue]\fB\fBmailbot\fR(1)\fR\m[]\&\s-2\u[4]\d\s+2,
303 \fBegrep\fR(1),
304 \fBgrep\fR(1),
305 \fBsendmail\fR(8)\&.
306 .SH "AUTHOR"
307 .PP
308 \fBSam Varshavchik\fR
309 .RS 4
310 Author
311 .RE
312 .SH "NOTES"
313 .IP " 1." 4
314 reformail
315 .RS 4
316 \%http://www.courier-mta.org/maildrop/reformail.html
317 .RE
318 .IP " 2." 4
319 \fBxfilter\fR
320 .RS 4
321 \%http://www.courier-mta.org/maildrop/maildropfilter.html#xfilter
322 .RE
323 .IP " 3." 4
324 \fBgetaddr\fR
325 .RS 4
326 \%http://www.courier-mta.org/maildrop/maildropfilter.html#getaddr
327 .RE
328 .IP " 4." 4
329 \fBmailbot\fR(1)
330 .RS 4
331 \%http://www.courier-mta.org/maildrop/mailbot.html
332 .RE
333 .IP " 5." 4
334 \fBmaildrop\fR(1)
335 .RS 4
336 \%http://www.courier-mta.org/maildrop/maildrop.html
337 .RE
338 .IP " 6." 4
339 \fBmaildropfilter\fR(7)
340 .RS 4
341 \%http://www.courier-mta.org/maildrop/maildropfilter.html
342 .RE