New user question re selective forwarding

New user question re selective forwarding

am 16.08.2006 21:07:13 von Jim McCullars

Greetings:

I have been experimenting with procmail at the request of a campus user
who wants to selectively forward emails (based on the [purported] sender)
to another email address. So to experiment, I am playing with my own email
account (on campus) to forward emails from campus users to my home address.
In other words, if the sender ends in @uah.edu or @something.uah.edu, I want
to forward it to my home bellsouth.net address.

Here is my .procmailrc file:

LOGABSTRACT=all
LOGFILE=$HOME/.procmail/log
VERBOSE=yes
FROM="^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"
:0c
* $ ${FROM}.+@(.+\.)?uah\.edu
! jimmcc1@bellsouth.net

Which I adapted from a FAQ file on the procmail.org site. It does the
forwarding OK, but it forwards everything. If I send myself email from off
campus, it should not forward, but it does. Here is the log:

procmail: [21737] Wed Aug 16 13:50:16 2006
procmail: Assigning "FROM=^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"
procmail: Match on "^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?.+@(.+\.)?uah\.edu"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi jimmcc1@bellsouth.net"
From jimmcc1@bellsouth.net Wed Aug 16 13:50:16 2006
Subject: test from bellsouth
Folder: /usr/sbin/sendmail -oi jimmcc1@bellsouth.net 1423
procmail: Bypassed locking "/var/mail/mccullj.lock"
procmail: Assigning "LASTFOLDER=/var/mail/mccullj"
procmail: Opening "/var/mail/mccullj"
procmail: Acquiring kernel-lock
procmail: Executing "/usr/sbin/sendmail,-oi,jimmcc1@bellsouth.net"
procmail: Notified comsat: "mccullj@15185711:/var/mail/mccullj"
From jimmcc1@bellsouth.net Wed Aug 16 13:50:16 2006
Subject: test from bellsouth
Folder: /var/mail/mccullj

And here is the message that triggered the above test:

Received: from smtp-in1.uah.edu (smtp-in1.uah.edu [146.229.1.210])
by email.uah.edu (8.13.5/8.13.5) with ESMTP id k7GIoF8d021735
for ; Wed, 16 Aug 2006 13:50:15 -0500 (CDT)
Received: from imf23aec.mail.bellsouth.net (imf23aec.mail.bellsouth.net [205.152.59.71])
by smtp-in1.uah.edu (8.13.6/8.13.1) with ESMTP id k7GIoDeG028508
for ; Wed, 16 Aug 2006 13:50:13 -0500 (CDT)
Received: from ibm66aec.bellsouth.net ([192.168.16.253])
by imf23aec.mail.bellsouth.net with ESMTP
id <20060816185007.DPHC5233.imf23aec.mail.bellsouth.net@ibm66aec.bellsouth.net>
for ; Wed, 16 Aug 2006 14:50:07 -0400
Received: from mail.bellsouth.net ([192.168.16.253])
by ibm66aec.bellsouth.net with SMTP
id <20060816185007.PFTR828.ibm66aec.bellsouth.net@mail.bellsouth.net>
for ; Wed, 16 Aug 2006 14:50:07 -0400
X-Mailer: Openwave WebEngine, version 2.8.16.1 (webedge20-101-1106-101-20040924)
X-Originating-IP: [146.229.5.22]
From:
To:
Subject: test from bellsouth
Date: Wed, 16 Aug 2006 14:50:07 -0400
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Message-Id: <20060816185007.PFTR828.ibm66aec.bellsouth.net@mail.bellsouth.net>
X-Scanned-By: MIMEDefang 2.56 on 146.229.1.210
X-UID: 28871


test from bellsouth

So how is it that mail sent from my bellsouth.net address matches the FROM
test in my .procmailrc file? Admittedly, this is my first attempt at
procmail, but I am obviously missing something. Thanks for any advice...

Jim McCullars
University of Alabama in Huntsville

Re: New user question re selective forwarding

am 17.08.2006 00:19:11 von AK

Jim McCullars wrote:

> Greetings:
>
> I have been experimenting with procmail at the request of a campus user
> who wants to selectively forward emails (based on the [purported] sender)
> to another email address. So to experiment, I am playing with my own email
> account (on campus) to forward emails from campus users to my home address.
> In other words, if the sender ends in @uah.edu or @something.uah.edu, I want
> to forward it to my home bellsouth.net address.
>
> Here is my .procmailrc file:
>
> LOGABSTRACT=all
> LOGFILE=$HOME/.procmail/log
> VERBOSE=yes
> FROM="^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"
> :0c
> * $ ${FROM}.+@(.+\.)?uah\.edu
> ! jimmcc1@bellsouth.net
>
> Which I adapted from a FAQ file on the procmail.org site. It does the
> forwarding OK, but it forwards everything. If I send myself email from off
> campus, it should not forward, but it does. Here is the log:
>
> procmail: [21737] Wed Aug 16 13:50:16 2006
> procmail: Assigning "FROM=^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"
> procmail: Match on "^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?.+@(.+\.)?uah\.edu"
> procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi jimmcc1@bellsouth.net"
> From jimmcc1@bellsouth.net Wed Aug 16 13:50:16 2006
> Subject: test from bellsouth
> Folder: /usr/sbin/sendmail -oi jimmcc1@bellsouth.net 1423
> procmail: Bypassed locking "/var/mail/mccullj.lock"
> procmail: Assigning "LASTFOLDER=/var/mail/mccullj"
> procmail: Opening "/var/mail/mccullj"
> procmail: Acquiring kernel-lock
> procmail: Executing "/usr/sbin/sendmail,-oi,jimmcc1@bellsouth.net"
> procmail: Notified comsat: "mccullj@15185711:/var/mail/mccullj"
> From jimmcc1@bellsouth.net Wed Aug 16 13:50:16 2006
> Subject: test from bellsouth
> Folder: /var/mail/mccullj
>
> And here is the message that triggered the above test:
>
> Received: from smtp-in1.uah.edu (smtp-in1.uah.edu [146.229.1.210])
> by email.uah.edu (8.13.5/8.13.5) with ESMTP id k7GIoF8d021735
> for ; Wed, 16 Aug 2006 13:50:15 -0500 (CDT)
> Received: from imf23aec.mail.bellsouth.net (imf23aec.mail.bellsouth.net [205.152.59.71])
> by smtp-in1.uah.edu (8.13.6/8.13.1) with ESMTP id k7GIoDeG028508
> for ; Wed, 16 Aug 2006 13:50:13 -0500 (CDT)
> Received: from ibm66aec.bellsouth.net ([192.168.16.253])
> by imf23aec.mail.bellsouth.net with ESMTP
> id <20060816185007.DPHC5233.imf23aec.mail.bellsouth.net@ibm66aec.bellsouth.net>
> for ; Wed, 16 Aug 2006 14:50:07 -0400
> Received: from mail.bellsouth.net ([192.168.16.253])
> by ibm66aec.bellsouth.net with SMTP
> id <20060816185007.PFTR828.ibm66aec.bellsouth.net@mail.bellsouth.net>
> for ; Wed, 16 Aug 2006 14:50:07 -0400
> X-Mailer: Openwave WebEngine, version 2.8.16.1 (webedge20-101-1106-101-20040924)
> X-Originating-IP: [146.229.5.22]
> From:
> To:
> Subject: test from bellsouth
> Date: Wed, 16 Aug 2006 14:50:07 -0400
> MIME-Version: 1.0
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 7bit
> Message-Id: <20060816185007.PFTR828.ibm66aec.bellsouth.net@mail.bellsouth.net>
> X-Scanned-By: MIMEDefang 2.56 on 146.229.1.210
> X-UID: 28871
>
>
> test from bellsouth
>
> So how is it that mail sent from my bellsouth.net address matches the FROM
> test in my .procmailrc file? Admittedly, this is my first attempt at
> procmail, but I am obviously missing something. Thanks for any advice...
>
> Jim McCullars
> University of Alabama in Huntsville
>

your from could match an entry on the received line
received: from hostname by your mail server apparantly to
youremail@email.uah.edu.

Change your recipe to:
:0c
* $ ${FROM}\/.+@(.+\.)?uah\.edu
! jimmcc1@bellsouth.net

and you'll see the variable MATCH set to the data that matched.

AK

Re: New user question re selective forwarding

am 17.08.2006 00:57:47 von Alan Connor

On comp.mail.misc, in , "Jim
McCullars" wrote:

> Greetings:
>
> I have been experimenting with procmail at the request
> of a campus user who wants to selectively forward emails
> (based on the [purported] sender) to another email address.
> So to experiment, I am playing with my own email account
> (on campus) to forward emails from campus users to my home
> address. In other words, if the sender ends in @uah.edu
> or @something.uah.edu, I want to forward it to my home
> bellsouth.net address.
>



Don't see it, Jim. Try simplifying the regex and see what
happens:

* ^(From|Reply-To|Sender|Return-Path): .*uah\.edu

If that works, put the first part in the variable and add
elements to both parts until it glitches again.

Have you set up a procmail test system yet? There's one on my
website:

http://home.earthlink.net/~alanconnor/proctest.html

and Timo Salmi describes another approach in:

http://www.uwasa.fi/~ts/info/proctips.html

Alan

--
Challenge-Response Systems are the best garbage-mail blockers
in the world. Spammers and trolls can't beat them and you
don't need to be a geek to use them. A brief introduction:
http://home.earthlink.net/~alanconnor/cr.html

Re: Re: New user question re selective forwarding

am 17.08.2006 00:57:57 von unknown

Post removed (X-No-Archive: yes)

Re: New user question re selective forwarding

am 17.08.2006 06:54:15 von Garen Erdoisa

Jim McCullars wrote:
> Greetings:
>
> I have been experimenting with procmail at the request of a campus user
> who wants to selectively forward emails (based on the [purported] sender)
> to another email address. So to experiment, I am playing with my own email
> account (on campus) to forward emails from campus users to my home address.
> In other words, if the sender ends in @uah.edu or @something.uah.edu, I want
> to forward it to my home bellsouth.net address.
>
> Here is my .procmailrc file:
>
> LOGABSTRACT=all
> LOGFILE=$HOME/.procmail/log
> VERBOSE=yes
> FROM="^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"
> :0c
> * $ ${FROM}.+@(.+\.)?uah\.edu
> ! jimmcc1@bellsouth.net
>
> Which I adapted from a FAQ file on the procmail.org site. It does the
> forwarding OK, but it forwards everything. If I send myself email from off
> campus, it should not forward, but it does. Here is the log:
>
> procmail: [21737] Wed Aug 16 13:50:16 2006
> procmail: Assigning "FROM=^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"
> procmail: Match on "^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?.+@(.+\.)?uah\.edu"
> procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi jimmcc1@bellsouth.net"
> From jimmcc1@bellsouth.net Wed Aug 16 13:50:16 2006
> Subject: test from bellsouth
> Folder: /usr/sbin/sendmail -oi jimmcc1@bellsouth.net 1423
> procmail: Bypassed locking "/var/mail/mccullj.lock"
> procmail: Assigning "LASTFOLDER=/var/mail/mccullj"
> procmail: Opening "/var/mail/mccullj"
> procmail: Acquiring kernel-lock
> procmail: Executing "/usr/sbin/sendmail,-oi,jimmcc1@bellsouth.net"
> procmail: Notified comsat: "mccullj@15185711:/var/mail/mccullj"
> From jimmcc1@bellsouth.net Wed Aug 16 13:50:16 2006
> Subject: test from bellsouth
> Folder: /var/mail/mccullj
>

After doing a few tests here, I think what is happening is that your
expression may be matching the "Mailbox separator" line which takes the
string from the MAIL FROM: identity and uses it.

ie:
From

Your regular expression would match any of the following forms:

From

From: "anything"
Old-From: "anything"
X-From: "anything"
Resent-From: "anything"

Reply-To: "anything"
Old-Reply-To: "anything"
X-Reply-To: "anything"
Resent-Reply-To: "anything"

Sender: "anything"
Old-Sender: "anything"
X-Sender: "anything"
Resent-Sender: "anything"

The first one there ("From" followed by a space and no colon) isn't
normally displayed as part of the email headers, but is visible to
procmail as a valid header line and is visible if you use a text viewer
on a mailbox folder.

So, if you were to logon to your school account from home, and send a
mail to your school account using your school account name as the logon,
thus making it the envelope sender address, while setting the "From:
header to your home account, then your rule would still match the
envelope sender line and forward the email back to you.

heh

Try modifying the following line:

FROM="^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"

FROM="^()\/(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"

Then as AK suggested examine the contents of the MATCH variable to see
what data is actually being matched. AK put the match later on in the
string, the above location will match the entire regular expression.

--
Garen

Re: New user question re selective forwarding

am 17.08.2006 21:20:29 von Jim McCullars

AK wrote:

> your from could match an entry on the received line
> received: from hostname by your mail server apparantly to
> youremail@email.uah.edu.

That's it exactly. I changed the recipe as you suggested and it did show
a match on a "Received:" header:

procmail: [22309] Thu Aug 17 13:26:19 2006
procmail: Assigning "FROM=^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"
procmail: Assigning "MATCH="
procmail: Matched "Received: from smtp-in1.uah.edu (smtp-in1.uah.edu [146.229.1.210]) by email.uah.edu (8.13.5/8.13.5) with ESMTP id k7HIQJIJ022306 for procmail: Match on "^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?\/.+@(.+\.)?uah\.edu"

So now what I can't understand is how a "Received:" line matched. Anyone
see something I'm missing? Thanks...

Jim McCullars
University of Alabama in Huntsville

Re: New user question re selective forwarding

am 17.08.2006 21:29:02 von Jim McCullars

Alan Connor wrote:

> Have you set up a procmail test system yet? There's one on my
> website:

Haven't yet, but that is something I'll have to look at. Thanks for the
heads-up.

Jim McCullars
University of Alabama in Huntsville

Re: New user question re selective forwarding

am 17.08.2006 21:38:34 von Jim McCullars

Garen Erdoisa wrote:

> Try modifying the following line:

> FROM="^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"

> FROM="^()\/(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"

> Then as AK suggested examine the contents of the MATCH variable to see
> what data is actually being matched. AK put the match later on in the
> string, the above location will match the entire regular expression.

A-HA! That did the trick! Here is what matched:

procmail: Assigning "MATCH="
procmail: Matched "From jimmcc1@bellsouth.net Thu Aug 17 14:31:50 2006
Received: from smtp-in2.uah.edu (smtp-in2.uah.edu [146.229.1.211]) by email.uah.edu (8.13.5/8.13.5) with ESMTP id k7HJVoDF027181 for
The pattern that matched spans two lines. I think adding a dollar sign
to the end of my regex should take care of this. Thanks again...

Jim McCullars
University of Alabama in Huntsville

Re: New user question re selective forwarding

am 17.08.2006 23:26:13 von Jim McCullars

Jim McCullars wrote:

>> FROM="^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"

I think I have found the problem. Note the

\<

in the pattern. I thought it was there to match an angle bracket. However,
it appears to be a procmail extension that can match (among other things)
newlines. I couldn't figure out why my pattern was matching across lines
but that would appear to be it. Live and learn...

Jim McCullars
University of Alabama in Huntsville

Re: New user question re selective forwarding

am 18.08.2006 00:26:48 von Alan Connor

On comp.mail.misc, in , "Jim McCullars" wrote:
>
>
> Jim McCullars wrote:
>
>>> FROM="^(From |(Old-|X-)?(Resent-)?(From|Reply-To|Sender):)(.*\<)?"
>
> I think I have found the problem. Note the
>
> \<
>

> in the pattern. I thought it was there to match an angle
> bracket. However, it appears to be a procmail extension that
> can match (among other things) newlines. I couldn't figure out
> why my pattern was matching across lines but that would appear
> to be it. Live and learn...
>

I had the same thought, after searching man procmailrc for
"newline", but haven't been able to make it work in a simple
recipe...

Alan

--
Challenge-Response Systems are the best garbage-mail blockers
in the world. Spammers and trolls can't beat them and you
don't need to be a geek to use them. A brief introduction:
http://home.earthlink.net/~alanconnor/cr.html

Re: Re: New user question re selective forwarding

am 18.08.2006 00:27:03 von unknown

Post removed (X-No-Archive: yes)