All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 PATH=$HOME/bin:/usr/local/bin:/usr/bin:/bin
11 PMVAR=$HOME/.var/procmail
12 MAILFILT=$HOME/.etc/mailfilter
15 REPLIES=$MAILFILT/autoreplies
17 LOGFILE=${LOGFILE:-$PMVAR/log}
22 #NICE='/usr/bin/nice -20'
24 PROCMAIL="$NICE /usr/bin/procmail -p $PMDIR/procmailrc"
25 FORMAIL="$NICE /usr/bin/formail -f"
26 GREP="$NICE /bin/grep"
27 EGREP="$NICE /bin/egrep"
28 FGREP="$NICE /bin/fgrep"
31 DELIVER="$NICE /usr/lib/dovecot/deliver"
33 CRM114="$NICE /usr/share/crm114/mailreaver.crm -u $MAILFILT/crm114/"
34 SA_PREFS="$MAILFILT/spamassassin/user_prefs"
35 SPAMASSASSIN="$NICE /usr/bin/spamassassin --prefs-file=$SA_PREFS"
36 SPAMC="$NICE /usr/bin/spamc --log-to-stderr --no-safe-fallback"
37 #SPAMC="$SPAMASSASSIN"
38 TRAINER="$NICE $MAILFILT/bin/train"
40 VACATION="$NICE /usr/bin/vacation"
42 SQLITE="$NICE /usr/bin/sqlite3"
48 ORGMAIL=$HOME/BOUNCED-MAIL
50 # maximum message size for spam checking
51 SPAMCHECK_MAX_MESSAGE_SIZE=512000
53 # if crm114 is unsure and SA returns a score less-than-or-equal to this,
54 # autotrain crm114 with ham
55 CRM_UNSURE_SA_AUTOTRAIN_LIMIT_HAM=0.0
56 # if crm114 classifies a message as spam but SA returns a score
57 # less-than-or-equal to this, retrain crm114
58 CRM_MISCLASSIFY_SA_AUTOTRAIN_LIMIT_HAM=-1.0
59 # if crm114 is unsure and SA returns a score greater than this, autotrain
61 CRM_UNSURE_SA_AUTOTRAIN_LIMIT_SPAM=8.0
62 # if crm114 classifies a message as ham but SA returns a score
63 # greate than this, retrain crm114
64 CRM_MISCLASSIFY_SA_AUTOTRAIN_LIMIT_SPAM=11
66 ### constants used in rules
69 RE_MYDOMAIN="(.+\.)*madduck\.net"
70 RE_MAILRELAYS="(seamus|swan|clegg)\.madduck\.net"
73 RE_SPACE_NEWLINE="(^|$RE_SPACE)"
74 RE_FIRSTNAME="martin($RE_SPACE_NEWLINE+f(\.?|elix))?"
76 RE_EXTRACT_HEADER_VALUE="$RE_SPACE*\/$RE_NOT_SPACE.*"
77 RE_EMAILADDRESS="${RE_NOT_SPACE}+@${RE_NOT_SPACE}+\.[^ >]+"
79 DEJAVU_HEADER=X-Deja-Vu
82 DELAYED_QUEUE=$BASE/.delayed/
83 TICKLER_QUEUE=$BASE/.store/
84 DISCARD=$BASE/.discard/
86 #DISCARD="'|$DELIVER -m BASE.discard'"
88 DELAY_NEXT_WEEKEND='next sunday 28 hours ago' # fri night, 20:00
89 DELAY_TONIGHT='tomorrow 00:00 4 hours ago' # tonight at 20:00
90 DELAY_AFTERNOON='tomorrow 00:00 7 hours ago' # today at 17:00
92 OURDATE="`$BIN_DATE +'%s %Y%m%d.%H%M.%N %a, %d %b %Y %T %z'`"
94 *$ OURDATE ?? ^\/${RE_NOT_SPACE}+
95 { OURDATE_TS="$MATCH" }
97 *$ OURDATE ?? ^[0-9]+${RE_SPACE}+\/${RE_NOT_SPACE}+
98 { OURDATE_SHORT="$MATCH" }
100 *$ OURDATE ?? ^[0-9]+${RE_SPACE}+[0-9.]+${RE_SPACE}+\/.+
103 ### variables from the message
105 ### local recipient data
106 # user+foobar@my.domain.org
112 USER="${USER:-$LOGNAME}"
113 EXTENSION="${EXTENSION:-}"
114 LOCAL="${LOCAL:-$USER${EXTENSION:++$EXTENSION}}"
115 HOSTNAME="`hostname --fqdn`"
116 DOMAIN="${DOMAIN:-$HOSTNAME}"
117 RECIPIENT="${RECIPIENT:-$LOCAL@$DOMAIN}"
118 ID="$LOGNAME@$HOSTNAME"
121 INCLUDERC=$PMDIR/get-msgid
124 *$ ^From:$RE_EXTRACT_HEADER_VALUE
128 * FROM ?? ^.+<\/.+@[^>]+
129 { FROMEMAIL="$MATCH" }
132 * FROM ?? ^.+\(\/.+@[^\)]+
133 { FROMEMAIL="$MATCH" }
136 *$ FROM ?? ^\/$RE_EMAILADDRESS
137 { FROMEMAIL="$MATCH" }
140 * FROMEMAIL ?? ^".+"$
141 * FROMEMAIL ?? ^"\/[^"]+
142 { FROMEMAIL="$MATCH" }
144 # if $SENDER is undefined or not an email address, get it from the message
149 *$ ^Sender:$RE_EXTRACT_HEADER_VALUE
153 { SENDER="$FROMEMAIL" }
157 *$ ^Date:$RE_EXTRACT_HEADER_VALUE
161 *$ ^Subject:$RE_EXTRACT_HEADER_VALUE
166 * SUBJECT ?? =\?.+\?[QBqb]\?.+\?=
168 SUBJECT="`PERL_UNICODE=S perl -MEncode=decode -e \"print decode(\\\"MIME-Header\\\", \\\"$SUBJECT\\\") . \\\"\n\\\";\"`"
169 SUBJECT_ENCODED="$MATCH"
174 *$ ^X-Original-To:$RE_EXTRACT_HEADER_VALUE
175 { ORIGINAL_TO="$MATCH" }
178 { LOGLATER="NO ORIGINAL_TO: $MSGID" }
181 *$ ^X-Trained-As:$RE_EXTRACT_HEADER_VALUE
182 { TRAINED_AS="$MATCH" }
185 *$ ^X-Postponed:$RE_EXTRACT_HEADER_VALUE
186 { POSTPONED="$MATCH" }
188 # fix variable values for special cases
189 INCLUDERC=$PMDIR/normalise
192 * ORIGINAL_TO ?? ^\/[^@]+
193 { ORIG_LOCAL="$MATCH" }
196 * ORIGINAL_TO ?? .+@\/.+
197 { ORIG_DOMAIN="$MATCH" }
199 ### run-time variables
202 # a procmail-style flag, which is true if unset and false if set (to !).
203 # unset by dejavu if the message has already been seen by the filter (according
204 # to the X-Been-There header).
208 # set this to a folder if the message should be delivered elsewhere than the
213 # if set, cuases spamchecks to be skipped, value lists reason
217 # set by spamtrapped and eqdomains and used to bypass spamchecks and handle as
218 # spam immediately. The value identifies who unset the variable.
222 # if set, then the mailfilter is as sure as it gets that the message is spam.
223 # The value identifies who set the variable.
227 # if set, then the various spamchecks disagree about spaminess of the mail.
228 # The value can hold additional information.
232 # if set, then the various spamchecks are unsure about spaminess of the mail.
233 # The value can hold additional information.
237 # if set, the spamchecks were skipped. The value gives the reason for
242 # if set, causes spamfilters to be retrained, according to the variable's value
246 # if set, contains reason why justme message was passed
250 # if set, disables delaying messages
254 * ? test -e $HOME/procmail.nodelays
255 { DISABLE_DELAYS=true }
258 # used to alter the timezone for delay calculations
262 # argument to /bin/date -d to indicate a message delay. This is overridden by
267 # /bin/date time expression indicating the time at which a message is to be
268 # released. Overrides DELAY.
272 # when set, causes mails to be marked as read when delivered. Can be
273 # initialised with DELIVER_READ
274 MARK_READ=$DELIVER_READ