POSTED TO USENET GROUP(S): comp.sys.next.misc
Greetings all!
I have been working on the following procmail receipe for awhile now, with
help from the procmail mailing list folks.
My original goal was pretty simple: when I get a read receipt returned to me,
I want the Subject of the message to tell me what the Subject of the message
was which had the read receipt on it.
For example, if I send Joe and email with the subject "Hey how are you?" and
put a read receipt on it, when Joe reads it I will get a message back with
the Subject 'Read Receipt'. Well, I file all my read receipts into one
mailbox, so I end up with a bunch of messages with the Subject 'Read
Receipt'. If I send Joe 12 messages, how do I know which one this Read
Receipt was on?
Well, the recipe below looks in the body for the Subject of my email to him
and turns it into the Subject line of the Read Receipt, so that when the
above-mentioned Read Receipt comes in, it says
Hey how are you?
as the Subject.
Well, several people pointed out that my original method was a little too
loose, and might have mismatches. My solution worked only for English Read
Receipts and would break for any others. This didn't seem like a good idea
for a global Internet, so I added support for French and German (the only
non-English read receipts I had).
Anyway, since I had finally gotten it working and thought that others in the
NeXT community might benefit from it, and the procmail group could see the
outcome of its help to me.
So here it is. If you have other language Read Receipts, please let me know
and I can add support for them as well.
Note the BUG! notice at the bottom of the receipe
############################################################################
#
# parse-read-receipts.rc - put the old Subject into the Read Receipt Subject
#
# TjL <luomat(_at_)peak(_dot_)org>
#
# v.1.0 (28 Jun 1997)
#
# How I started:
# The original subject is enclosed in " marks.
# so we throw out anything before the first " and after the
# second ".
#
# However, since the Subject itself may have had " marks in it,
# we opt to get the whole string before the first ", which is
# static
#
# Your message regarding "
#
# and we try to make sure that the end part also matches, so we
# take as much as we can, which turns out to be:
#
# " of
# (Note: there is a space after the 'of')
# now this works, as long as the Read Receipt is in English
#
# Using just ' "' and '" ' would work for all languages, but
# would fail on Subjects that included them in it. This does not
# seem to be acceptable, even for the benefit of international
# compatibility. However, checking my read receipts Mailbox,
# I could only find French and German read receipts. I am sure
# there are other languages out there which support Read Receipts
# but I do not know what they are. Adding support for them should
# be trivial.
#
# ENGLISH: '^Your message regarding '' and '" of '
# FRENCH: '^Votre message concernant "' and '" de '
# GERMAN: '^Ihre Mitteilung bezueglich "' and '" vom '
#
# USAGE NOTE:
# In my main .procmailrc file, I include this by checking for
# the Subject and the Received: by NeXT.Mailer line, like this
#
# :0
# * ^Subject: Read Receipt$
# * ^Received: by NeXT\.Mailer
# { INCLUDERC=${HOME}/.procmail/rcfiles/parse-read-receipts.rc }
#
# where this file is ${HOME}/.procmail/rcfiles/parse-read-receipts.rc
#
# That is the best I could think of to minimize mis-matching on
# messages have the Subject "Read Receipt" but are not actually
# read receipts. The body matching should make sure that nothing
# is done if the expected patterns are not met.
#
# The '$' should make sure that Subject such as 'Read Receipts are neat'
# are not matched.
#
# One last note:
# The 'E' flag = 'else' ie if the previous recipe did not match
# so if you get mostly German read receipts you should change
# the order to save some processing time, etc etc.
:0 B
* Your message regarding
{
# This is an English read receipt
SUBJECT=`formail -I "" |\
sed 's/^Your\ message\ regarding\ \"//g'| \
sed 's/\"\ of\ .*//g' |\
tr -s '\012' ' ' `
}
:0 EB
* Votre message concernant
{
# This is a French read receipt
SUBJECT=`formail -I "" |\
sed 's/^Votre\ message\ concernant\ \"//g'| \
sed 's/\"\ de\ .*//g' |\
tr -s '\012' ' ' `
}
:0 EB
* Ihre Mitteilung bezueglich
{
# This is a German read receipt
SUBJECT=`formail -I "" |\
sed 's/^Ihre\ Mitteilung\ bezueglich\ \"//g'| \
sed 's/\"\ vom\ .*//g' |\
tr -s '\012' ' ' `
}
:0 E
{
# This is either a Read Receipt in an unknown
# language, or a message with the Subject 'Read Receipt'
# that is not actually a Read Receipt
SUBJECT=`formail -xSubject:`
}
# insert the new Subject line
:0fhw
|formail -i"Subject: $SUBJECT"
# append the message to the Read-Receipts mailbox
# you can change this if you want.
#
# BUG! If this has gotten this far and is not a read receipt
# but a message with the Subject 'Read Receipt' it still
# ends up in the Read Receipt mailbox
#
# 'appnmail' comes with the mailapp-utilities package
# and does its own locking, so no further locking is required
:0
| appnmail Read-Receipts
# end of 'parse-read-receipts.rc'