Procmail issue

jdow jdow at earthlink.net
Thu Jan 24 09:26:42 UTC 2013


That does not seem to match what I broke down as the rule.

Whose account is getting filtered. That will help analyze the
rule. The loop through GMail is muddying the water here. And note
that you CANNOT do the "else" clause without a clone operation. I
presume that is what the GMail loop kludge is supposed to do.

Without the loops through GMail what is it you are trying to accomplish?

Let's break this down to what you really want to do to email that
is coming in and who are ALL the people whose email are being processed?

If you subtract out the loop are you trying to make a courtesy copy to
one or more other addresses for all mail that is coming in? Your
brief description below suggests that is the case. But the whole GMail
loop is "undocumented" so it's hard to guess what really gets done.

Who all SHOULD be getting copies?

The forwarded lines really obfuscate the GMail end of things, since it
seems to be a loop and you're trying to avoid the loop.

I think procmail is doing exactly what you wrote when you forgot there
is no DWIM flag on procmail. I'm not sure, from your description,
whether it is ever possible to match the second rule if the first
rule matches. Certainly the second rule never gets played if the
first rule passed. And if the first rule passes an email through
it also will fall through the second rule.

1) So let's get incoming addresses, even if its "foo1 at gmail" and
"foo2Qpoof" as long as the number of addresses is right.

2) How is this email getting to procmail?

3) What end results are you expecting?

4) What happens when you send the email to kraish4 at gmail.com?

5) Are you concerned about CC?

6) Are you concerned about BCC? (Which may not be possible to handle
in all cases.

Sometimes going through the problem definition again can clarify the
path to a solution.

{^_^}

On 2013/01/24 00:20, Ashley M. Kirchner wrote:
> Let's try this:
>
> In simple form, it looks like this:
>
> if (message does NOT contain header) {
>    send to GMail
> } else {
>    drop in recipient mailbox
>    send copy to other email
> }
>
> The first recipe works, as specified, and does what it should do which is to
> check whether an incoming e-mail to the system contains that specific header
> line.  If the message does not, that e-mail gets bounced out to GMail instead.
> (Gmail's job here is simply filtering and forwarding it back.)  Done, end of
> processing.
>
> When the message comes back from GMail, it will have that X-Forwarded-For line
> in it, in which case the recipe sees it and exits, and the message gets dropped
> in the user's mailbox.
>
> That's it, that's what the first recipe does.  It works.  Note: this is NOT a
> system wide recipe.  It's user specific, namely my account only.  I'm simply
> forwarding a copy to a coworker, but only after things come back from GMail's
> filter, not before.
>
> I'm trying to add to that by sending a copy of the message after it's been
> returned from GMail (and therefore contains the header already) to another
> e-mail address as well as dropping it in the recipient's mailbox.
>
> The reason I have those two lines at the beginning of the second recipe is to
> make sure the only messages being copied are those that contain that header.
> Otherwise, I may end up sending duplicates of the same message, once when it
> first arrives, and again when it comes back from GMail.  At least, I think
> that's what will happen if I omit those lines.  I could be wrong.
>
>
>
> On Thu, Jan 24, 2013 at 12:34 AM, jdow <jdow at earthlink.net
> <mailto:jdow at earthlink.net>> wrote:
>
>     OK, you do not want things to continue processing. So what I posted will
>     not solve your problem.
>
>     So what you have for rule 1 is:
>          not Xforwarded to both kirash4 at gmail.com <mailto:kirash4 at gmail.com> and
>     ashley at pcraft.com <mailto:ashley at pcraft.com>
>     and not xforwarded to both kirash4 at gmail.com <mailto:kirash4 at gmail.com> and
>     ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>
>     and not from kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>     and not to            ashley at papillon.pcraft.__com
>              forward to kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>
>     What you have for rule two is the first half of rule 1 to another
>     recipient:
>          not Xforwarded to both kirash4 at gmail.com <mailto:kirash4 at gmail.com> and
>     ashley at pcraft.com <mailto:ashley at pcraft.com>
>     and not xforwarded to both kirash4 at gmail.com <mailto:kirash4 at gmail.com> and
>     ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>
>              forward to salesdept at wherever
>
>
>     Is this a general rule for all mail coming into the system to any
>     recipient? Presuming it is then email to george at gmail.com
>     <mailto:george at gmail.com> will be
>     sent off to kirash and processing ends there since it fails all the
>     conditions and the conditions are anded and inverted.
>
>     Mail to kirash will fall through both rules.
>
>     Mail from kirash will match the third test which means it's false
>     when inverted and the mail falls through to the second rule and gets
>     forwarded to salesdept.
>
>     mail to ashley will fall through the first rule and be diverted salesdept
>     by the second rule.
>
>     Mail that has been xforwarded to kirash and ashley (at either address)
>     passes one of the first two rules which when inverted fails the procmail
>     rule for both rules 1 and 2 so they simply pass through.
>
>     So have account phil at phoo.com <http://phoo.com> send a message to
>     george at pcraft.com <mailto:george at pcraft.com>
>     and see what happens. I believe it should pass through. So you'd see
>     both rules hitting. You can forge a test message and feed it through
>     procmail to see what happens with the rule.
>
>     For testing let's try this set of rules:
>
>     :0
>     * !^X-Forwarded-For: kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>     <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>> ashley at pcraft.com
>     <mailto:ashley at pcraft.com> <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>>
>     * !^X-Forwarded-For: kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>     <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>> ashley at pcigrafx.com
>     <mailto:ashley at pcigrafx.com> <mailto:ashley at pcigrafx.com
>     <mailto:ashley at pcigrafx.com>>
>     * !^From.*kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>     <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>     * !^To.*ashley at papillon.pcraft.____com <mailto:ashley at papillon.__pcraft.com
>     <mailto:ashley at papillon.pcraft.com>>
>     /tmp/foo1
>
>     0:
>     * ^X-Forwarded-For: kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>     <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>> ashley at pcraft.com
>     <mailto:ashley at pcraft.com> <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>>
>     * ^X-Forwarded-For: kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>     <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>> ashley at pcigrafx.com
>     <mailto:ashley at pcigrafx.com> <mailto:ashley at pcigrafx.com
>     <mailto:ashley at pcigrafx.com>>
>     /tmp/foo2
>
>     /tmp/foo3
>
>     That should sort the mail to three different destinations in /tmp. You
>     can easily see where the messages go as you try variants without polluting
>     mail boxes.
>
>     I'm wondering about this line in the first rule:
>     * !^From.*kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>     <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>
>     Is that really what you mean? I presume it is. But if it's not that could
>     lead to confusing results when you test.
>
>     {^_^}
>
>
>     On 2013/01/23 20:15, Ashley M. Kirchner wrote:
>
>         No, the second rule should ONLY process when a message passes the first rule
>         (and does NOT get bounced out to gmail.)  I believe, please correct me
>         if I'm
>         wrong here, but I believe the way you've rewritten it, rule 2 will
>         ALWAYS run,
>         regardless of the outcome of rule 1.  This will result in duplicate message
>         being sent to the second e-mail address.
>
>
>         On Wed, Jan 23, 2013 at 9:10 PM, jdow <jdow at earthlink.net
>         <mailto:jdow at earthlink.net>
>         <mailto:jdow at earthlink.net <mailto:jdow at earthlink.net>>> wrote:
>
>              The basic rule to remember with procmail is that once the email is
>              delivered processing is ended. So if the rule passes you must then
>              clone the email and deliver the clone. That allows the rules to keep
>              on processing.
>
>              I imagine you also want the second rule to continue processing as well.
>
>              Something akin to
>              :0
>              * !^X-Forwarded-For: kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>         ashley at pcraft.com <mailto:ashley at pcraft.com> <mailto:ashley at pcraft.com
>         <mailto:ashley at pcraft.com>>
>
>
>              * !^X-Forwarded-For: kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>         ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>
>         <mailto:ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>>
>              * !^From.*kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>              * !^To.*ashley at papillon.pcraft.____com
>         <mailto:ashley at papillon.__pcraft.com <mailto:ashley at papillon.pcraft.com>>
>              {
>                       :0 c
>                       ! kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>              }
>
>              :0c
>
>              * ^X-Forwarded-For: kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>         ashley at pcraft.com <mailto:ashley at pcraft.com> <mailto:ashley at pcraft.com
>         <mailto:ashley at pcraft.com>>
>
>              * ^X-Forwarded-For: kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>         ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>
>         <mailto:ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>>
>
>              {
>                       :0 c
>                       ! salesdept
>              }
>
>              {^_^}
>
>
>              On 2013/01/23 20:00, Ashley M. Kirchner wrote:
>
>                  The way this should work is as follows:
>
>                  - new e-mail arrives at the recipient's box and procmail picks
>         it up and
>                  checks
>                  the X-Forward-For header
>                  - if the header does NOT contain any of those listed, it
>         forwards the
>                  message to
>                  the specified gmail address
>                      > STOP <
>
>                  - if the header exists and contains any of the matches listed, the
>                  message gets
>                  dropped into the recipient's inbox
>                  AND
>                  - it is at this point that I want it to also forward a copy of said
>                  message to
>                  the second e-mail address
>
>
>                  The first rule works as expected.  Message comes in, first rule
>         checks
>                  it and
>                  upon failing, bounces back out to gmail.  Nothing happens after
>         that.
>                    When the
>                  message returns, it passes the first rule and gets dropped in the
>                  recipient's
>                  box.  When I added the second rule, nothing changed.  The first
>         keeps
>                  running as
>                  is and the second is simply ignored.
>
>                  Now, perhaps I'm wrong in thinking that when it comes back and
>         passes
>                  the first
>                  rule, it will also run through the second rule.  Is this a case
>         where I
>                  need to
>                  write things wrapped in a nest?  Sort of like an IF .. THEN ..
>         ELSE?
>
>                  A
>
>
>
>                  On Wed, Jan 23, 2013 at 7:50 PM, jdow <jdow at earthlink.net
>         <mailto:jdow at earthlink.net>
>                  <mailto:jdow at earthlink.net <mailto:jdow at earthlink.net>>
>                  <mailto:jdow at earthlink.net <mailto:jdow at earthlink.net>
>         <mailto:jdow at earthlink.net <mailto:jdow at earthlink.net>>>> wrote:
>
>                       On 2013/01/23 15:28, Ashley M. Kirchner wrote:
>
>                           Ok, I'm still trying to figure this out.  On the new, test
>                  account, i
>                           can get it
>                           to log so I just need to figure out the other two.
>           However, I
>                  recreated the
>                           same recipe on the test account and what I'm seeing in
>         the log
>                  is the
>                           first part
>                           of the recipe only, it doesn't seem to do anything
>         with the
>                  second part.
>
>                           So this (adjusted for the test account):
>
>                           LOGFILE=/var/log/procmail
>                           VERBOSE=yes
>
>                           :0
>                           * !^X-Forwarded-For: kirash4 at gmail.com
>         <mailto:kirash4 at gmail.com>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>
>                           <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>>
>         mytest at pcigrafx.com <mailto:mytest at pcigrafx.com>
>         <mailto:mytest at pcigrafx.com <mailto:mytest at pcigrafx.com>>
>                  <mailto:mytest at pcigrafx.com <mailto:mytest at pcigrafx.com>
>         <mailto:mytest at pcigrafx.com <mailto:mytest at pcigrafx.com>>>
>
>                           <mailto:ashley at pcigrafx.com
>         <mailto:ashley at pcigrafx.com> <mailto:ashley at pcigrafx.com
>         <mailto:ashley at pcigrafx.com>>
>                  <mailto:ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>
>         <mailto:ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>>>>
>
>                           * !^X-Forwarded-For: kirash4 at gmail.com
>         <mailto:kirash4 at gmail.com>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>
>                           <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>>
>         mytest at pcraft.com <mailto:mytest at pcraft.com> <mailto:mytest at pcraft.com
>         <mailto:mytest at pcraft.com>> <mailto:mytest at pcraft.com
>         <mailto:mytest at pcraft.com>
>
>                  <mailto:mytest at pcraft.com <mailto:mytest at pcraft.com>>>
>         <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>
>                  <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>>
>
>                           <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>
>         <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>>>>
>                           * !^From.*kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>
>                           <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>>
>                           * !^To.*mytest at papillon.pcraft.______com
>                  <mailto:mytest at papillon.
>         <mailto:mytest at papillon.>__pcra__ft.com <http://pcraft.com>
>         <mailto:mytest at papillon.__pcraft.com <mailto:mytest at papillon.pcraft.com>>>
>                           <mailto:ashley at papillon <mailto:ashley at papillon>.
>                  <mailto:ashley at papillon
>         <mailto:ashley at papillon>.>__pcr__a__ft.com <http://pcra__ft.com>
>         <http://pcraft.com>
>
>                  <mailto:ashley at papillon.
>         <mailto:ashley at papillon.>__pcra__ft.com <http://pcraft.com>
>         <mailto:ashley at papillon.__pcraft.com <mailto:ashley at papillon.pcraft.com>>>>
>                           ! kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>
>
>                  <mailto:ashley at gmail.com <mailto:ashley at gmail.com>
>         <mailto:ashley at gmail.com <mailto:ashley at gmail.com>>
>
>                           <mailto:ashley at gmail.com <mailto:ashley at gmail.com>
>         <mailto:ashley at gmail.com <mailto:ashley at gmail.com>>>>
>
>                           :0c
>                           * ^X-Forwarded-For: kirash4 at gmail.com
>         <mailto:kirash4 at gmail.com>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>
>                           <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>>
>         mytest at pcigrafx.com <mailto:mytest at pcigrafx.com>
>         <mailto:mytest at pcigrafx.com <mailto:mytest at pcigrafx.com>>
>                  <mailto:mytest at pcigrafx.com <mailto:mytest at pcigrafx.com>
>         <mailto:mytest at pcigrafx.com <mailto:mytest at pcigrafx.com>>>
>                           <mailto:ashley at pcigrafx.com
>         <mailto:ashley at pcigrafx.com> <mailto:ashley at pcigrafx.com
>         <mailto:ashley at pcigrafx.com>>
>
>                  <mailto:ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>
>         <mailto:ashley at pcigrafx.com <mailto:ashley at pcigrafx.com>>>>
>
>                           * ^X-Forwarded-For: kirash4 at gmail.com
>         <mailto:kirash4 at gmail.com>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>
>                           <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>
>                  <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>
>         <mailto:kirash4 at gmail.com <mailto:kirash4 at gmail.com>>>>
>         mytest at pcraft.com <mailto:mytest at pcraft.com> <mailto:mytest at pcraft.com
>         <mailto:mytest at pcraft.com>> <mailto:mytest at pcraft.com
>         <mailto:mytest at pcraft.com>
>
>                  <mailto:mytest at pcraft.com <mailto:mytest at pcraft.com>>>
>         <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>
>                  <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>>
>
>                           <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>
>         <mailto:ashley at pcraft.com <mailto:ashley at pcraft.com>>>>
>                           ! salesdept at pcraft.com <mailto:salesdept at pcraft.com>
>         <mailto:salesdept at pcraft.com <mailto:salesdept at pcraft.com>>
>                  <mailto:salesdept at pcraft.com <mailto:salesdept at pcraft.com>
>         <mailto:salesdept at pcraft.com <mailto:salesdept at pcraft.com>>>
>                           <mailto:salesdept at pcraft.com
>         <mailto:salesdept at pcraft.com> <mailto:salesdept at pcraft.com
>         <mailto:salesdept at pcraft.com>>
>                  <mailto:salesdept at pcraft.com <mailto:salesdept at pcraft.com>
>         <mailto:salesdept at pcraft.com <mailto:salesdept at pcraft.com>>>__>
>
>
>
>                       Ashley, it might pay to explicitly say, in words, what you
>         think you
>                       want to do if the first rule passes, if the first rule
>         does not pass
>                       and the second rule passes, and if neither rule passes.
>
>                       As it is your description of passing the first rule is the
>         correct
>                       action for what you've developed as a rule. You have
>         delivered the
>                       email and rule processing ceases at that point. So you
>         might have
>                       to clone the output of the first rule to pass it to the
>         second rule
>                       IF that is the action you want based on your
>         disappointment at these
>                       rules doing what you told them to do.
>
>                       {^_^}


More information about the users mailing list