[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Qmail, procmail, to: , subject: , <LITEMPLATE>



After messing around with this for ages I thought I'd put it on the list for
others.

Apologies:
- More a procmail how-to that a mhonarc how-to
- This has been dealt with in the list in other ways (I couldn't find
anything of use to me; I'm not a developer)
- Neater way is to edit source or use $field('to') in rc file

This describes how to include the To: field in the Subject: line in
<LITEMPLATE> when piping mail into an archive from QMail using procmail:

/home/user/.qmail file:

|preline procmail


/home/user/.procmail.rc file:

#(insert thes line for debug only)
#LOGFILE     = /home/cyberbcc/pm.log
#LOGABSTRACT = "all"
#VERBOSE     = "on"

SHELL       = /bin/sh

#This pulls out the Date: field and removes the leading
#space, in case you need this for a Wilma script
:0
* ^Date:\/.*
{
  DATEX ="$MATCH"
  DATEXNEW = `echo $DATEX | sed 's/^[ ]*//'`
}

#This pulls out the Delivered-To:, in case you need this for Wilma.
#The cut strips the @domain from the email address
:0
* ^Delivered-To:\/.*
{
  DELTO = "$MATCH"
  DELTONEW = `echo $DELTO | cut -d'@' -f1`
}

#This pulls out the To: field
#The 2nd Variable assignment
#turns "user@xxxxxxxxxx" <user@xxxxxxxxxx> into user@xxxxxxxxxx
:0
* ^To:\/.*
{
  TORCP = "$MATCH"
  TORCPNEW = `echo $TORCP | cut -d'"' -f2`
}

#The clincher. This adds the To: field to the Subject: field
:0 fwH
* ^Subject:\/.*
|sed -e "s/Subject:[ ]*/Subject: To: $TORCPNEW - /gi"

#This is local to my set up,
#but shows how to send some of the above variables to a wilma
#script containing a call to mhonarc
:0
| /usr/local/bin/wilma.local.pl.cyberbcc $DELTONEW $DATEXNEW


Garreth


[Index of Archives]     [Bugtraq]     [Yosemite News]     [Mhonarc Home]