At 18:23 2006-04-12 -0400, Greg Rowe wrote:
[snip]
:0 fw
* ^Content-type:.*(multipart/.*;|text/html;)
|/usr/local/bin/stripmime.pl
:0 w
! -oi -f "$SENDER" "$@"
Messages coming into the gateway for <number>@domain1.com are checked and
converted to plain text if necessary and then sent on to that paging
gateway.
It is the To: field you're using? Is this one of the params passed? That
would seem better to use than parsing the message.
This code here will parse the To: header. Some mods, and you could make it
operate on the $@ variable. If there are multiple addresses in the To:
field, you'll end up with just the FIRST one. The formail bit might seem
unnecessary (why not just use $MATCH, right?), but what it does for us is
strips out comments (and, well, subsequent addresses).
# get the To: address as an address component ONLY (no comments)
:0
* ^To:[ ]*\/[^ ].*
{
CLEANTO=`echo "From: ${MATCH}" | formail -rzxTo:`
}
# username portion
:0
* CLEANTO ?? ^\/[^(_at_)]+
{
TO_USER=$MATCH
}
# domain portion
:0
* CLEANTO ?? @\/.*
{
TO_DOMAIN=$MATCH
}
just add:
$TO_USER(_at_)domain2(_dot_)tld
To your sendmail invocation. Check your logfile to see what the parm order
currently is - you should probably add this to the very end, rather than
between the from address specification and the original args (which is
where you're picking up your recipient, so it seems as if you should be
able to parse $@ for the necessary address (and apply the TO_USER type of
transform to it).
Thus, you'd insert the above code, plus the following recipe just before
your final recipe in your file:
:0 w
* ^Subject: you little snot
! -oi -f "$SENDER" "$@" ${TO_USER}(_at_)domain2(_dot_)tld
(whether the added bit appears before or after "$@" depends upon the args
currently in $@ - if it ENDS with address, then put the new address after
it, and if it STARTS with the delivery address, put the new address before it)
FTR, you're not filtering, so what's the net purpose of the w flag on your
delivery? I've included it above only because that's the syntax you're
using, but you should consider what happens with the message either way.
As I'm sure this solves some otherwise time-consuming problem for you, you
now owe me a (good, unused) beer. <g>
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
____________________________________________________________
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