procmail
[Top] [All Lists]

Procmail. problem handling multiple recipients in serverwide config.

2008-05-12 16:34:33
Hi all,

I'm new to this list, so am checking this lists archives for this as we
speak, as I don't believe I am the first to want to do what I need to.

I have been googling this for about a week now, and seems that most stuff I
can find is the per user recipes. (we run virtual users on postfix so
mailbox_command=procmail just doesn't, thus I have procmail running from
postfix as a serverwide config.)

What I am trying to do is get it to handle email for one account, as well as
aliases to that user, to move it to different folders according to which
alias or tag* it has. My current config works fine assuming its sent to only
the alias, but not if that alias (or account) is matched with multiple
recipients in the TO: header.

*Tag: just an insertion to the subject applied by sed (see below)

It seems when its sent to multiple recipients procmail gets a run per
recipient, but matches the To: line each time (for the relevant alias) thus
adds the stamp and drops it in the Maildir 3 times (...if there are 3
recipients, 4 times if there are 4 etc). It doesn't deliver the mail to the
other recipients in the To: header (either locally or abroad :-).

I think the help I could use is some good tips for a good way to strip the
matched recipient from the To: header and redeliver to the remaining
recipients.

some(_dot_)test(_at_)valex is the actual mailbox, another.test@ and gmac.test@ 
are the
2 aliases.

my procmailrc;

LOGFILE=/var/log/procmail.log
DROPPRIVS=yes
VERBOSE=on
SENDER="<$1>"
SHIFT = 1

#sent to another(_dot_)test(_at_)valex without a stamp. apply a stamp and
#deliver (this is one variation to try make it work, using braces)
:0
* ^To:(_dot_)*another(_dot_)test(_at_)valex(_dot_)com(_dot_)au
{
        :0 fwH
        * !^Subject: .*\[ANOTHER\].*
        |sed -e 's/^Subject:[   ]*/Subject: [ANOTHER] /'

          #tried to do this to fool procmail to do what I need.
          #Worked in one way (only putting one copy in the folder)
          #but doesn't deliver to the other recipients.
        #:0 Wh: msgid.lock
        #| formail -D 8192 msgid.cache

        :0
        #* ^To:(_dot_)*another(_dot_)test(_at_)valex(_dot_)com(_dot_)au(_dot_)*
        #* ^Subject: .*\[ANOTHER\].*

/var/spool/mail/virtual/valex.com.au/some.test/.SMALLCLIENTS.ANOTHER/

}


#sent to gmac(_dot_)test(_at_)valex without a stamp, so add one and deliver
#(the original recipe to do what I want)
:0 fwH
* ^To:(_dot_)*gmac(_dot_)test(_at_)valex(_dot_)com(_dot_)au(_dot_)*
* !^Subject: .*\[GMACTEST\].*
|sed -e 's/^Subject:[   ]*/Subject: [GMACTEST] /'

:0
* ^To:(_dot_)*gmac(_dot_)test(_at_)valex(_dot_)com(_dot_)au(_dot_)*
* ^Subject: .*\[GMACTEST\].*
/var/spool/mail/virtual/valex.com.au/some.test/.SMALLCLIENTS.GMACTEST/



#some.test with stamp not sent to alias
:0
* ^To:(_dot_)*some(_dot_)test(_at_)valex(_dot_)com(_dot_)au(_dot_)*
* ^Subject: .*\[ANOTHER\].*
/var/spool/mail/virtual/valex.com.au/some.test/.SMALLCLIENTS.ANOTHER/

#some.test with stamp not sent to alias
:0
* ^To:(_dot_)*some(_dot_)test(_at_)valex(_dot_)com(_dot_)au(_dot_)*
* ^Subject: .*\[GMACTEST\].*
/var/spool/mail/virtual/valex.com.au/some.test/.SMALLCLIENTS.GMACTEST/


# Work around procmail bug: any output on stderr will cause the "F" in
"From"
# to be dropped.  This will re-add it.
:0
* ^^rom[ ]
{
  LOG="*** Dropped F off From_ header! Fixing up. "

  :0 fhw
  | /bin/sed -e '1s/^/F/'
}


# send everything else back to sendmail for delivery
:0:/var/tmp/sendmail.lockfile
| /usr/sbin/sendmail -oi -f "$SENDER" "$@"

---

Thanks in advance for any assistance/recommendations.

--
Regards
Nick


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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