procmail
[Top] [All Lists]

MORE procmail writing vars to file

1999-04-10 21:44:13
I maintain a website that has an email contact page that
uses a CGI script to fire off email to a particular
email account.  The email contact page is a form so the
CGI can write the names of html textboxes and their values 
and the name of the checkbox array and all checkbox values that
are checked into the body of the email.  I use procmail to 
check the body of the incoming email to see who it should 
be forwarded to.

Here is what the body of an email looks like:

==========================================
This is for:        Contact site Admin
                    Club President
                    
Message for this AGC:       
                          
Coach or Team Manager for:  
                               
                               
                               
Subject:  Summer sign-up    
Senders Name:  Chad Robbins      
Senders email:   cr(_at_)aol(_dot_)com

Please send us information on summer sign ups.
========================


The email header info, which I show you here, is nearly useless 
to me, since I (the html page and CGI) am the sender every time:
I only note the "From" to forward a copy of every email to one
person who coordiantes responses.

*************
To: myaccount(_at_)purple(_dot_)com
From: purple
Subject: purple: 
Submitted by: unknown(_at_)12-20(_dot_)dynamic(_dot_)purple(_dot_)com 
(http_referer=http://www.purple.com/~myaccount/contactus/contact.html)
*************

The procmail that works now searches the body of the email
and forwards the  email to whomever is selected via html
checkboxes.  Here is the procmail - with a few changes made
by suggestion of this procmail list:

=============================================
SHELL=/bin/sh
MAILDIR=/home/purple/Mail
LOGFILE=/home/purple/procmail.log
LOGABSTRACT = "all"
VERBOSE= "on"

CLUB_PRESIDENT=ddd(_at_)oasch-inc(_dot_)com
ADMIN=bozo(_at_)aik(_dot_)com
TREASURER=hbl(_at_)planet(_dot_)info(_dot_)net
COPYALL=bigcheese(_at_)aol(_dot_)com

:0
* ^From MAILER-DAEMON
/dev/null

:0c
* ^Subject purple 
! $COPYALL

:0 Bc
* Club President
! $CLUB_PRESIDENT

:0 Bc
* Admin
! $ADMIN

:0 Bc
* Club Treasurer
! $ADMIN
==============================

The copyall is to send a copy of all email to one
monitoring person.  It gets trigged by the header
subject line.  Also, the "c" option everywhere seems
to let the email fall though and one copy of the email
ends up in the mailbox of the account that the CGI
is sending to, namely myaccount(_at_)purple(_dot_)com

A problem with this scheme is that if someone cancels
their email account, or if they never check it, the
person who sends in the email won't get any response.

I have already written a perl script which updates a
html page by posting data from a second page. It operates
by appending while file copying.  It functions
like an un-attended bulletin board.  I want to use this
same perl script in the following fashion.  I want to 
leave the log file alone (I use it for error checking). I
want to write the data  

Subject:  Summer sign-up    
Senders Name:  Chad Robbins      
Senders email:   cr(_at_)aol(_dot_)com

contained in the body of the email to a file, and then
read this file in and update a html page where people to
whom email has been forwarded fill in check boxes to say
they 1) received the email 2) dealt with it.  The person
to whom all email goes ($COPYALL) will take over and deal
with responses to emails that no one responded to.

I can't for the life of me figure out how to test the body
for the text "Subject" and bring back "Subject:  Summer sign-up" 
etc. for the other two fields as well.


:0 wci:
* ^Subject:[    ]\/[^   ].*
| echo "Subject is: " $MATCH  >>$HOME/BHmail_log

indeed writes the Subject (purple) into the file BHmail_log.

How do I match on the body text and strip out the data the user
inputted?  Is it a seperate recipe for
each of the three cases?  I think the suggestion was to have
three recipes strip three cases and then echo when they are
all done.  Probably at the very end.  If someone could, please
give very specific examples.  I am truely confused about matching
and the first recipe lines.

Regards  Tom





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