# (W) 2009 Alan W. Rateliff, II # # procmail recipe to automatically generate case numbers for emails # received without subjects, and auto-reply with a subject reflecting # the case number, and a message contained in ~/nosubject.txt # detailing what has been done with the original message. # # The recipe rewrites the Subject line before delivering it # locally, which is probably bad behavior, but no more than # important emails with no subject. This does not break signed # messages since only the body is signed, not the headers. # # The case number is a simple checksum of the current time and date, # which generates a nice and simple 10-digit number. You can use # other sources for the checksum, like the current PID or a random # number, whatever you like. But I recommend staying away from # other algorithms; I thought of using CRC32 or MD5, but the # numbers generated are far too unruly to be practical, especially # if you wanted to modify this to assign case numbers to ALL # emails instead of just those missing subjects. Although, you # could use awk to truncate the generated number. Just a thought # as you can ultimately do anything you desire. # # I am not sure if I should have used a lock file (:0:), but never # the less, this recipe works, and works well. # :0 * !^FROM_DAEMON * !^FROM_MAILER * !^X-Loop: nosubject_reply * ^Subject:([ ]$|$) { :0 fw | CASE=`date "+%Y%m%d %k%M%S"|cksum|awk '{print $1}'`; \ formail -A"X-Loop: nosubject_reply" \ -t -i"Subject: Support case $CASE" # # I use a customized dmail on my system to deliver to mbx-formatted # mailboxes contained within directories. If you do not use dmail # on your system, change the action below to # $DEFAULT # :0 cw | /usr/local/bin/dmail -q :0 hw | (formail -rtk -A"Precedence: junk (autoreply)" -A"From: \"-your full name-\" "; \ cat $HOME/nosubject.txt) | $SENDMAIL -t }