Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

procmail match and forward

Status
Not open for further replies.

RottPaws

Programmer
Mar 1, 2002
478
US
I have a procmail recipe that looks for a particular X-header and when it finds it, it extracts the email address behind it and forwards the email to that address.

Code:
[b]procmail recipe[/b]
    :0c BH
      * ^X-Sender: \/[^ ]+
      ! $MATCH

This works fine as long as the only thing behind the X-header is a straight email address.

Code:
[b]X-header[/b]
X-Sender: user.name@domain.com

[b]procmail log[/b]
procmail: Assigning "MATCH="
procmail: Matched "user.name@domain.com"
procmail: Match on "^X-Sender: \/[^ ]+"
procmail: Executing "/usr/sbin/sendmail,-oi,user.name@domain.com"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi user.name@domain.com"

But if there is a real name involved, it doesn't handle it right.

Code:
[b]X-header[/b]
X-Sender: "Real Name" <user.name@domain.com>

[b]procmail log[/b]
procmail: Assigning "MATCH="
procmail: Matched ""Real"
procmail: Match on "^X-Sender: \/[^ ]+"
procmail: Executing "/usr/sbin/sendmail,-oi,"Real"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi "Real"

[i]Results in an unknown user error[/i]
(reason: 550 5.1.1 <Real@myserver.domain.com>... User unknown)
    (expanded from: "Real)

I tried changing the RegEx and it did actually send it to the X-Sender email , but it didn't exactly fix the problem.
Code:
[b]X-header[/b]
X-Sender: "Real Name" <user.name@domain.com>

[b]procmail log[/b]
procmail: Assigning "MATCH="
procmail: Matched "[COLOR=red yellow]"Real Name" <user.name@domain.com>[/color]"
procmail: Match on "^X-Sender: \/[COLOR=red yellow].+[/color]"
procmail: Executing "/usr/sbin/sendmail,-oi,"Real[COLOR=red yellow],[/color]Name"[COLOR=red yellow],[/color]<user.name@domain.com>"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi "Real Name" <user.name@domain.com>"

[i]Results in an unknown user errors[/i]
(reason: 550 5.1.1 <Real@myserver.domain.com>... User unknown)
    (expanded from: "Real)

(reason: 550 5.1.1 <Name@myserver.domain.com>... User unknown)
    (expanded from: Name)

So......my question: Is there a way to get procmail to match the full email address and use it in a sendmail execution without replacing the spaces with commas?

_________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
I had the same problem with my vacation recipe and I'm using this

FGREP=/bin/fgrep
TO=`formail -x To:`
FIRST=`echo "$TO" |sed -n '1p'| awk -F"<" '{print $2}'`
FIRSTX=`echo "$FIRST" | awk -F"@" '{print $1}'`

There probably is a more elegant way to do it but it's working for me

Norm
 
Thanks for the info. I'll give it a try and see what happens.

_________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top