]> 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:

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