I want to write a rule that behaves like the following.
1. Any mail that is sent to me must pass either of the two conditions to
get through.
1.match the approved recipients list.
Define $FORMAIL to reflect your system. Define $FRIENDS to point to a
file that contains the list of approved recipients. I don't know exactly
what you mean by "get through". The way it works below is that if the
email is from an approved recipient, then it gets put into $DEFAULT.
FROM=`$FORMAIL -rt -x'To:'`
#
# Check to see if this email is from a "friend". If so, stick it
#in my
# INBOX.
#
:0
* ? echo "$FROM" | egrep -i -f $FRIENDS
$DEFAULT
2.contain the correct code in the subject header to be submitted
for entry into the approved recipients list. This means that this
message will be read by myself and I shall manually add that user
to the list.
With this recipe, any "Subject" that contains the correct code (what I
call a "magicword", will get placed into $DEFAULT. You need to define
$MAGIGWORD which in the below example is case *sensitive* to what you
want.
MAGICWORD="password"
# I prefer to define it as below because it makes for easy change.
# MAGICWORD=`cat $HOME/magicword`
#
# Check to see if this email contains the "magic word" in the
# "Subject:". If so, stick it
# in my INBOX.
#
:0D:
* $^[Ss][Uu][Bb][Jj][Ee][Cc][Tt]:.*$MAGICWORD
$DEFAULT
any other mail I want discarded and resent back to the recipient with
instructions on how to get added to the approved recipients list. I also
want to return the original message back to the recipient.
Ok, this is a bit more complex, but still should be easy to follow.
PMDIR and PMDIRp point to particular directories where I want things
grabbed from or put to. I call `sed` to insert my MAGICWORD into the
autorespond file. I also have this set up so it will `gzip` all the
bounced email contents into a file so you can examine them later.
MDAEMON="Tim's Mailer Daemon <bodysurf(_at_)netcom(_dot_)com>"
PRECJUNK="Precedence: Junk"
XLEWP="X-Lewp: $MDAEMON"
# If it's gotten this far, the email is either from a potential
# friend or an unknown enemy. What is done now is to send the
# person back a polite reply telling them of why their email has
# been rejected and how to get their email to me should they do
# desire.
#
# And let's gzip and save the email in case this is buggy :^o
#
:0c
| ($FORMAIL -rk -p'> ' -i"Subject: SORRY FOR THE INCONVENIENCE" \
-i"From: $MDAEMON" -i"$XLEWP" -i"$PRECJUNK"; \
sed "s/MAGICWORD/$MAGICWORD/" $PMDIR/unknown-reply) | \
$SENDMAIL -oi -t
:0a:
| gzip -fc >> $PMDIRp/bounced-emails.gz
I plan to randomize the code necessary to get approved which means I'll
retain a record of which code is expected by which recipient.
I have this set up so one code works for anyone. If you want a different
code for each recipient, that will be more work.
I'll handle mailing list mail a little differently :-)
Some questions.
1. How do I capture the text of the original message? Do I have to archive
it in a temporary file for my reply recipe to use later?
`formail` can capture the text of the body and use it when you autoreply
which is probably the easiest way and is how I send the original body back
to the recipient in the above recipe.
3. I'm tempted to write the majority of the logic in a perl script and
just use that as a filter. However my ISP will only let me use Perl 5
Alpha 5 circa 1992 and procmail
If you want to that's fine. However what you want done could be done
easily in `procmail` which is far less of a burden to your system than
firing up a `perl` script normally.
procmail v3.10 1994/10/31
Anybody see any benefit in upgrading to a later procmail?
Yes. Less bugs :^)
[snip]
Lates!
---------------------------------------------------------------------------
Tim <bodysurf(_at_)pobox(_dot_)com>
mailto:bodysurf(_at_)pobox(_dot_)com
Finger bodysurf(_at_)pobox(_dot_)com for my PGP public key (Bits 1024/KeyID
09DA5C49).
PGP Key FPrint (09/03/94): 4C 97 F1 FA 70 55 68 91 49 D1 AD F2 DD 63 0C 15
---------------------> Please PGP encrypt your email <---------------------