mail replies to glog.sh with mglog.sh
There's a companion script for glog.sh, named mglog.sh, which allows
to receive replies to glog (or phlog, if you prefer) entries by e-mail.
It can be used as a filter in a procmail recipe, for example like
:0 cH
* ^TOyourlogin+phlog@
| $HOME/bin/mglog.sh
It filters out the From: and Subject: headers with formail, puts
the sender address after some obscuring (to prevent spam address
harvesting) into the reply appended to the glog entry referenced
to in the subject.
As it is up and running on my glog, you could reply therefore to
this very entry by sending e-mail to yargo+glog.at.jerq.org with
the subject "g093281249".
Here is my current version of mglog.sh:
#!/bin/sh
# wrapper for procmail launching of glog.sh
# $Id: mglog.sh,v 1.7 2007/03/07 13:53:32 yargo Exp $
# get header fields and keep body
formail -c -k -X From: -X Subject: | {
read h1 v1
read h2 v2
# fields can be in whatever order, so check
if [ "$h1" = "Subject:" ] ; then
subj="$v1"
from="$v2"
else
subj="$v2"
from="$v1"
fi
# truncate sender's address to prevent spamming
# and eliminate <>
from=$(echo $from|sed -e 's/@[^.]*/@_HIDDEN_/' -e 's/[<>]//g')
# remove stupid quoting from subject, if present
subj=${subj%\?=}
subj=${subj#=\?ISO*Q\?}
# limit message size to 10kB
dd bs=1k count=10 2>/dev/null | {
# sender will become subject of glog entry, subject is message-id
# append only; prefix&root as defined in environment (GLOG_ROOT,GLOG_PREFIX)
/sys/sdf/bin/glog.sh -a -b -s "by $from" "$subj"
}
}