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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
.\" DSTART
.\"
.\" maildrop - mail delivery agent with filtering abilities
.\"
.\" Copyright 1998, Double Precision Inc.
.\"
.\" This program is distributed under the terms of the GNU General Public
.\" License. See COPYING for additional information.
.\" DEND
.TH maildropex 5 "August 31, 1998" "Double Precision, Inc." ""
.\" $Id: maildropex.html 1.1 1998/04/23 00:25:23 mrsam Exp $
.SH NAME
maildropex \- examples of maildrop filtering language
.br
.br
.SH "SYNOPSIS
$HOME/.mailfilter, $HOME/.mailfilters/*
.br
.br
.SH "DESCRIPTION
If \fI$HOME/.mailfilter\fP exists, filtering instructions in this file
will be carried out prior to delivering the message. The filtering instructions
may direct \fImaildrop\fP to discard the message, save the message in a different
mailbox, or forward the message to another address. If \fI$HOME/.mailfilter\fP
does not exist, or does not end up providing explicit delivery instructions,
\fImaildrop\fP delivers the message to the user's system mailbox.
.PP
The files in \fI$HOME/.mailfilters\fP are used when \fImaildrop\fP is invoked
in embedded mode.
.br
.br
.SH "EXAMPLES
Take all mail that's sent to the 'auto' mailing list, and save it in the
'Mail/auto' mailbox. The 'auto' mailing list software adds a "Delivered-To:
auto@domain.com" header to all messages submitted to the list:
.nf
if (/^Delivered-To: *auto@domain\\.com$/)
to Mail/auto
.fi
.PP
After delivering the message via the "to" command, \fImaildrop\fP automatically
stops filtering and terminates without executing any other instructions
in the filter file.
.PP
Take all mail from 'boss@domain.com' about the current status of the
project, save it in the folder "Mail/project", then forward a copy to John.
.nf
if (/^From: *boss@domain\\.com/ \\
&& /^Subject:.*[:wbreak:]project status[:wbreak:]/)
{
cc "!john"
to Mail/project
}
.fi
.PP
Note that it is necessary to use a backslash in order to continue the if
statement on the next line.
.PP
Keep copies of the last 50 messages that you received in the directory
'backup'. NOTE: 'backup' must be a \fImaildir\fP directory, not a mailbox.
You can create a maildir using the maildirmake command. maildirmake comes
with qmail, or if qmail is not installed,
a substitute command is provided as part of the \fImaildrop\fP package.
.nf
cc backup
`cd backup/new && rm -f dummy \\`ls -t | sed -e 1,50\\``
.fi
.PP
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 this filtering
language. If you make a mistake, and accidentally delete a message, you
can recover it from the backup/new subdirectory.
.PP
Save messages that are at least 100 lines long (approximately) into
Mail/IN.Large:
.nf
if ( $LINES > 100 )
to Mail/IN.Large
.fi
.PP
Send messages from the auto mailing list to the program 'archive', using
a lock file to make sure that only one instance of the archive program
will be running at the same time:
.nf
if (/^Delivered-To: *auto@domain\\.com$/)
dotlock "auto.lock" {
to "|archive"
}
.fi
.PP
Check if the Message-ID: 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:
.nf
`reformail -D 8000 duplicate.cache`
if ( $RETURNCODE == 0 )
exit
.fi
.PP
The reformail command maintains a list of
recently seen Message-IDs in the file "duplicate.cache".
.PP
Here's 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:
.nf
cc $DEFAULT
xfilter "reformail -r -t"
/^To:.*/
getaddr($MATCH) =~ /^.*/;
flock "vacation.lock" {
`fgrep -iqx "$MATCH" vacation.lst 2>/dev/null || { \\
echo "$MATCH" >>vacation.lst ; \\
exit 1 ; \\
} `
}
if ( $RETURNCODE == 0 )
exit
to "| ( cat - ; echo ""; cat vacation.msg) | $SENDMAIL"
.fi
.PP
This code maintains a list of everyone who sent you mail in the file called
"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 "vacation.msg" are mailed back to the sender. This is intended to
provide a short acknowledge to people that you will not be answering mail
for a short period of time.
.PP
The first statement saves the original message in your regular mailbox.
Then, xfilter is used to generate
an autoreply header to the sender. The "To:" header in the autoreply -
which was the sender of the original message - is extracted, and the getaddr()
function is used to strip the person's name, leaving the address only.
The file "vacation.lst" is checked, using a lock file to guarantee atomic
access and update (overkill, probably). Note that the backslashes are required.
.PP
If the address is already in the file, \fImaildrop\fP exits, otherwise contents
of vacation.msg are appended to the autoreply header, and mailed out.
.br
.br
.SH "SEE ALSO
maildrop(1), maildropfilter(1),
reformail(1), egrep(1), grep(1), sendmail(8),
http://www.qmail.org
|