procmail
[Top] [All Lists]

Re: assign a unique ID to each incoming email?

1999-04-07 21:19:01
Thanks,

I tried that, but still have problems with it. I am trying to assign
a new ticket number when the incoming mail did not already contain
a ticket-number in its Subject header n the form [S-ABUSE-xxxx]:

Here is the part of my recipe:

--cut here---
[...]
# check if the mail already has a TICKET in its subject
PREFIX="S-ABUSE"
:0 Whc
* ^Subject:.*\[${PREFIX}-\/[0-9][^]]+.*
{
        TICKET=$MATCH
        OLD=1
}

############################################### setup ............ serial number
## Assign a serial number to this mail. The number is kept in the external    ##
## file $MAILDIR/serial.rc. This section uses a global lock for serialization.  
 ##
##   NOTE: the rc file must exist and be seeded with a non-negative value.    ##
## This can be eliminated at the cost of a test -f for each message.          ##
################################################################################
LOCKFILE=serial.rc$LOCKEXT                                              ## set 
global lock
INCLUDERC=$MAILDIR/serial.rc                                            ## read 
current value (whether we us it or not)
:0 Ec                                                                   ## 
increment
* $ $SERIAL^0                                                           ##  
value just read
*       1^0                                                             ##  by 1
{ SERIAL=$=                                                             ##  
save new value in variable
  TICKET=$SERIAL                                                        ##  say 
we use this serial as ticket number
  :0 w i c                                                              ##  and 
update the
  | print -- "# Serial numbers assigned beginning v5.8 19971117\n\      ## 
history
    # Last message v$REV with header date: $FDT $TZ\n#\n\               ## 
date-time stamp
    SERIAL=$SERIAL" > $INCLUDERC                                        ##  and 
serial number in the rc file
}                                                                       ##
LOCKFILE                                               
[...]
--cut here---


serial.rc contains a single line:
--cut here---
SERIAL=1
--cut here--

However, this is what happens (from my procmaillog, verbose):


--cut here---
[...]
procmail: Assigning "PREFIX=S-ABUSE"
procmail: No match on "^Subject:.*\[${PREFIX}-\/[0-9][^]]+.*"
procmail: Assigning "LOCKFILE=serial.rc.lock"
procmail: Locking "serial.rc.lock"
procmail: Assigning "INCLUDERC=/home/abuse/mail/serial.rc"
procmail: Assigning "SERIAL=1"
procmail: Score:       0       0 "##  value just read"
procmail: Score:       0       0 "##  by 1"
procmail: Skipped "junk"
[...]
--cut here---


Could anyone tell me why the scoring doesn't work?

TIA