procmail
[Top] [All Lists]

How to

2001-03-12 03:09:41
I just managed to set up a mail loop, or at least I was able to
bombard myself with 400 copies of one mail. I am trying email
anonymizers for my class. STudents write to
penpals-anonymous(_at_)my(_dot_)school and according to who their partner
is, it is forwarded on, but without the original From: address.

Although I have had no problem with one that statically
paired partners, I want to create the pairings on the
fly. In particular I want the pairs to be created in order of the
arrival of the first emails. The problem this means that I will
have emails that can't be delivered to their final recipients
until the next email comes. Perhaps I could put a lock on some
procmail process to have procmail do the storage of these email,
but it could be a week before the next one comes, and in the case
of an odd number of students, forever. 

So I decided to try to save them and extract data that will
enable me to send them on from a file later. The problem is how
to do this from my .procmailrc (actually .exprc). What I tried is:

  :0
  |formail -s procmail -m .exprc < Mail/$GROUP/$PARTNER_ID

But this produced the mail loop. Should I try to pursue this or
take the course of letting procmail lock the mail until the next
mail comes? 

My .exprc file follows. I will send some LOG files if there is
any interest.

SHELL=/bin/sh
PATH=/bin:/usr/bin:/usr/home/lang/bin:$HOME/bin
ORGMAIL=$HOME/Maildir/
MAILDIR=$HOME
DEFAULT=$HOME/Mail/mbox   #completely optional
LOGFILE=$HOME/.procmail/explog
VERBOSE=on

####
# My penpal anonymizer
##

:0
*^TOpenpals-anonymous@(ms\.)?chinmin\.edu\.tw
* ! ^FROM_DAEMON
* ! ^X-Loop: penpals-anonymous@(ms?\.)chinmin\.edu\.tw
{
  #Get the email address from the mail
  SENDER_ADDRESS=`formail -rtzxTo:`

  # Get all the data out of the mail. Uses a perl script
  VITAE=`$HOME/anonymous.pl testads $SENDER_ADDRESS pairs`

  # trap for addresses not in ads
  :0
  * VITAE ?? bad_address
  {
   :0 c
   | (formail -r -I"Subject: Penpal mail not sent: New address not in list" \
                  -A"X-Loop: penpals-anonymous" ; \
        echo "Contact Greg Matheson 
<lang(_at_)ms(_dot_)chinmin(_dot_)edu(_dot_)tw> "; \
        echo "or send your email again from your old address. ") | $SENDMAIL -t

   :0:
   notsent
  } 

  # trap for addresses not in groups
  :0
  * VITAE ?? wrong_group
  {
   :0 c
   | (formail -r -I"Subject: Penpal mail not sent: Address not in 
penpals-anonymous list" \
                  -A"X-Loop: penpals-anonymous" ; \
        echo "Contact Greg Matheson 
<lang(_at_)ms(_dot_)chinmin(_dot_)edu(_dot_)tw> "; \
        echo "or send your email again from the right address. ") | $SENDMAIL -t

   :0:
   notsent
  } 

  :0
  * VITAE ?? group: \/[^         ]*
  { GROUP = $MATCH
  }

  :0
  * VITAE ?? sender-id: \/[^     ]*
  { SENDER_ID = $MATCH
  }

  :0
  * VITAE ?? partner-address: \/[^       ]*
  { PARTNER_ADDRESS = $MATCH

  }

  #keep subject, add X-Loop, From:, send it
  :0 
  | formail -k -XSubject: -I "X-Loop: penpals-anonymous" -XX-Loop: -I "From: 
penpals-anonymous" -XFrom: | $SENDMAIL $SENDMAILFLAGS $PARTNER_ADDRESS

  :0
  * VITAE ?? partner-id: \/[^    ]*
  { PARTNER_ID = $MATCH

  :0
  |formail -s procmail -m .exprc < Mail/$GROUP/$PARTNER_ID
  }

}

-- 
GREG Matheson
Chinmin College, Taiwan
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>