]> git.madduck.net Git - etc/mailfilter.git/blob - procmail/delay-delivery

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

remove some non-spamtraps
[etc/mailfilter.git] / procmail / delay-delivery
1 # create table messages (msgid text unique not null, filename text
2 # primary key not null unique, release_ts integer not null);
3
4 #TODO: create config/delay-(disabled|tonight|weekend)
5
6 :0
7 * DELAY ?? .
8 * ! DELAYED ?? .
9 {
10   :0
11   * DELAY ?? ^[0-9]
12   { DELAY="now + $DELAY" }
13
14   #TODO: for tickling, use header date
15   RELEASE="`$BIN_DATE -d \"$DELAY\" +'%s %c'`"
16
17   :0
18   *$ RELEASE ?? ^\/${RE_NOT_SPACE}+
19   { RELEASE_TS=$MATCH }
20
21   :0
22   *$  $RELEASE_TS ^0
23   *$ -$OURDATE_TS ^0
24   {
25     :0
26     *$ RELEASE ?? ^[0-9]+${RE_SPACE}+\/.+
27     { RELEASE_TIME="$MATCH" }
28
29     LOG="delay:       delay delivery of $MSGID until $RELEASE_TIME$NL"
30
31     DELAYED_QUEUE_DB=$PMVAR/delayed-queue.sqlite
32     DO_QUERY="$SQLITE $DELAYED_QUEUE_DB"
33
34     DATA="$MSGID"
35     INCLUDERC=$PMDIR/sql-escape
36
37     Q="insert into messages values
38       ($DATA, '\\'\$DESTFILE\\'', $RELEASE_TS)"
39     TRAP="$TRAP; $DO_QUERY '$Q'"
40
41     :0 fw
42     |$FORMAIL -I "X-Delayed: $RELEASE_TS ($RELEASE_TIME)"
43
44     :0
45     $DELAYED_QUEUE
46   }
47 }