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 SQLITE="$NICE /usr/bin/sqlite3"
46 ORGMAIL=$HOME/BOUNCED-MAIL
48 # maximum message size for spam checking
49 SPAMCHECK_MAX_MESSAGE_SIZE=512000
51 # if crm114 is unsure and SA returns a score less-than-or-equal to this,
52 # autotrain crm114 with ham
53 CRM_UNSURE_SA_AUTOTRAIN_LIMIT_HAM=0.0
54 # if crm114 classifies a message as spam but SA returns a score
55 # less-than-or-equal to this, retrain crm114
56 CRM_MISCLASSIFY_SA_AUTOTRAIN_LIMIT_HAM=-1.0
57 # if crm114 is unsure and SA returns a score greater than this, autotrain
59 CRM_UNSURE_SA_AUTOTRAIN_LIMIT_SPAM=8.0
60 # if crm114 classifies a message as ham but SA returns a score
61 # greate than this, retrain crm114
62 CRM_MISCLASSIFY_SA_AUTOTRAIN_LIMIT_SPAM=11
64 ### constants used in rules
67 RE_MYDOMAIN="(.+\.)*madduck\.net"
68 RE_MAILRELAYS="(seamus|clegg)\.madduck\.net"
71 RE_SPACE_NEWLINE="(^|$RE_SPACE)"
72 RE_FIRSTNAME="martin($RE_SPACE_NEWLINE+f(\.?|elix))?"
74 RE_EXTRACT_HEADER_VALUE="$RE_SPACE*\/$RE_NOT_SPACE.*"
76 DEJAVU_HEADER=X-Deja-Vu
79 DELAYED_QUEUE=$BASE/.delayed/
80 TICKLER_QUEUE=$BASE/.store/
81 DISCARD=$BASE/.discard/
83 #DISCARD="'|$DELIVER -m BASE.discard'"
85 DELAY_NEXT_WEEKEND='next sunday 28 hours ago' # fri night, 20:00
86 DELAY_TONIGHT='tomorrow 00:00 4 hours ago' # tonight at 20:00
87 DELAY_AFTERNOON='tomorrow 00:00 8 hours ago' # today at 16:00
89 OURDATE="`$BIN_DATE +'%s %Y.%m.%d.%H.%M.%N %a, %d %b %Y %T %z'`"
91 *$ OURDATE ?? ^\/${RE_NOT_SPACE}+
92 { OURDATE_TS="$MATCH" }
94 *$ OURDATE ?? ^[0-9]+${RE_SPACE}+\/${RE_NOT_SPACE}+
95 { OURDATE_SHORT="$MATCH" }
97 *$ OURDATE ?? ^[0-9]+${RE_SPACE}+[0-9.]+${RE_SPACE}+\/.+
100 ### variables from the message
102 ### local recipient data
103 # user+foobar@my.domain.org
109 USER="${USER:-$LOGNAME}"
110 EXTENSION="${EXTENSION:-}"
111 LOCAL="${LOCAL:-$USER${EXTENSION:++$EXTENSION}}"
112 HOSTNAME="`hostname --fqdn`"
113 DOMAIN="${DOMAIN:-$HOSTNAME}"
114 RECIPIENT="${RECIPIENT:-$LOCAL@$DOMAIN}"
115 ID="$LOGNAME@$HOSTNAME"
118 INCLUDERC=$PMDIR/get-msgid
121 *$ ^From:$RE_EXTRACT_HEADER_VALUE
125 *$ FROM ?? ^\/${RE_NOT_SPACE}+@${RE_NOT_SPACE}+
126 { FROMEMAIL="$MATCH" }
129 * FROM ?? ^.+ <\/[^>]+
130 { FROMEMAIL="$MATCH" }
133 * FROM ?? ^.+ \(\/[^\)]+
134 { FROMEMAIL="$MATCH" }
136 # if $SENDER is undefined or not an email address, get it from the message
141 *$ ^Sender:$RE_EXTRACT_HEADER_VALUE
145 { SENDER="$FROMEMAIL" }
149 *$ ^Date:$RE_EXTRACT_HEADER_VALUE
153 *$ ^Subject:$RE_EXTRACT_HEADER_VALUE
158 * SUBJECT ?? =\?.+\?[QBqb]\?.+\?=
160 SUBJECT="`PERL_UNICODE=S perl -MEncode=decode -e \"print decode(\\\"MIME-Header\\\", \\\"$SUBJECT\\\") . \\\"\n\\\";\"`"
165 *$ ^X-Original-To:$RE_EXTRACT_HEADER_VALUE
166 { ORIGINAL_TO="$MATCH" }
169 { LOGLATER="NO ORIGINAL_TO: $MSGID" }
172 *$ ^X-Trained-As:$RE_EXTRACT_HEADER_VALUE
173 { TRAINED_AS="$MATCH" }
176 *$ ^X-Postponed:$RE_EXTRACT_HEADER_VALUE
177 { POSTPONED="$MATCH" }
179 # fix variable values for special cases
180 INCLUDERC=$PMDIR/normalise
183 * ORIGINAL_TO ?? ^\/[^@]+
184 { ORIG_LOCAL="$MATCH" }
187 * ORIGINAL_TO ?? .+@\/.+
188 { ORIG_DOMAIN="$MATCH" }
190 ### run-time variables
193 # a procmail-style flag, which is true if unset and false if set (to !).
194 # unset by dejavu if the message has already been seen by the filter (according
195 # to the X-Been-There header).
199 # set this to a folder if the message should be delivered elsewhere than the
204 # if set, cuases spamchecks to be skipped, value lists reason
208 # set by spamtrapped and eqdomains and used to bypass spamchecks and handle as
209 # spam immediately. The value identifies who unset the variable.
213 # if set, then the mailfilter is as sure as it gets that the message is spam.
214 # The value identifies who set the variable.
218 # if set, then the various spamchecks disagree about spaminess of the mail.
219 # The value can hold additional information.
223 # if set, then the various spamchecks are unsure about spaminess of the mail.
224 # The value can hold additional information.
228 # if set, the spamchecks were skipped. The value gives the reason for
233 # if set, causes spamfilters to be retrained, according to the variable's value
237 # if set, contains reason why justme message was passed
241 # if set, disables delaying messages
245 # argument to /bin/date -d to indicate a message delay. This is overridden by
250 # /bin/date time expression indicating the time at which a message is to be
251 # released. Overrides DELAY.
255 # when set, causes mails to be marked as read when delivered. Can be
256 # initialised with DELIVER_READ
257 MARK_READ=$DELIVER_READ