Re: Procmail issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx> 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@xxxxxxxxx and ashley@xxxxxxxxxx
and not xforwarded to both kirash4@xxxxxxxxx and ashley@xxxxxxxxxxxx
and not from          kirash4@xxxxxxxxx
and not to            ashley@papillon.pcraft.__com
        forward to kirash4@xxxxxxxxx

What you have for rule two is the first half of rule 1 to another
recipient:
    not Xforwarded to both kirash4@xxxxxxxxx and ashley@xxxxxxxxxx
and not xforwarded to both kirash4@xxxxxxxxx and ashley@xxxxxxxxxxxx
        forward to salesdept@wherever


Is this a general rule for all mail coming into the system to any
recipient? Presuming it is then email to george@xxxxxxxxx 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 send a message to george@xxxxxxxxxx
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@xxxxxxxxx <mailto:kirash4@xxxxxxxxx> ashley@xxxxxxxxxx <mailto:ashley@xxxxxxxxxx>
* !^X-Forwarded-For: kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx> ashley@xxxxxxxxxxxx <mailto:ashley@xxxxxxxxxxxx>
* !^From.*kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
* !^To.*ashley@papillon.pcraft.__com <mailto:ashley@papillon.pcraft.com>
/tmp/foo1

0:
* ^X-Forwarded-For: kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx> ashley@xxxxxxxxxx <mailto:ashley@xxxxxxxxxx>
* ^X-Forwarded-For: kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx> ashley@xxxxxxxxxxxx <mailto:ashley@xxxxxxxxxxxx>
/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@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>

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@xxxxxxxxxxxxx
<mailto:jdow@xxxxxxxxxxxxx>> 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@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
    ashley@xxxxxxxxxx <mailto:ashley@xxxxxxxxxx>


    * !^X-Forwarded-For: kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
    ashley@xxxxxxxxxxxx <mailto:ashley@xxxxxxxxxxxx>
    * !^From.*kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
    * !^To.*ashley@papillon.pcraft.__com <mailto:ashley@papillon.pcraft.com>
    {
             :0 c
             ! kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
    }

    :0c

    * ^X-Forwarded-For: kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
    ashley@xxxxxxxxxx <mailto:ashley@xxxxxxxxxx>

    * ^X-Forwarded-For: kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
    ashley@xxxxxxxxxxxx <mailto:ashley@xxxxxxxxxxxx>

    {
             :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@xxxxxxxxxxxxx
        <mailto:jdow@xxxxxxxxxxxxx>
        <mailto:jdow@xxxxxxxxxxxxx <mailto:jdow@xxxxxxxxxxxxx>>> 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@xxxxxxxxx
        <mailto:kirash4@xxxxxxxxx> <mailto:kirash4@xxxxxxxxx
        <mailto:kirash4@xxxxxxxxx>>
                 <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
        <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>>>
        mytest@xxxxxxxxxxxx <mailto:mytest@xxxxxxxxxxxx>
        <mailto:mytest@xxxxxxxxxxxx <mailto:mytest@xxxxxxxxxxxx>>

                 <mailto:ashley@xxxxxxxxxxxx <mailto:ashley@xxxxxxxxxxxx>
        <mailto:ashley@xxxxxxxxxxxx <mailto:ashley@xxxxxxxxxxxx>>>

                 * !^X-Forwarded-For: kirash4@xxxxxxxxx
        <mailto:kirash4@xxxxxxxxx> <mailto:kirash4@xxxxxxxxx
        <mailto:kirash4@xxxxxxxxx>>
                 <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
        <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>>>
        mytest@xxxxxxxxxx <mailto:mytest@xxxxxxxxxx> <mailto:mytest@xxxxxxxxxx

        <mailto:mytest@xxxxxxxxxx>> <mailto:ashley@xxxxxxxxxx
        <mailto:ashley@xxxxxxxxxx>

                 <mailto:ashley@xxxxxxxxxx <mailto:ashley@xxxxxxxxxx>>>
                 * !^From.*kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
        <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>>
                 <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
        <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>>>
                 * !^To.*mytest@papillon.pcraft.____com
        <mailto:mytest@papillon.__pcraft.com <mailto:mytest@papillon.pcraft.com>>
                 <mailto:ashley@papillon.
        <mailto:ashley@papillon.>__pcra__ft.com <http://pcraft.com>

        <mailto:ashley@papillon.__pcraft.com <mailto:ashley@papillon.pcraft.com>>>
                 ! kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
        <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>>

        <mailto:ashley@xxxxxxxxx <mailto:ashley@xxxxxxxxx>

                 <mailto:ashley@xxxxxxxxx <mailto:ashley@xxxxxxxxx>>>

                 :0c
                 * ^X-Forwarded-For: kirash4@xxxxxxxxx
        <mailto:kirash4@xxxxxxxxx> <mailto:kirash4@xxxxxxxxx
        <mailto:kirash4@xxxxxxxxx>>
                 <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
        <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>>>
        mytest@xxxxxxxxxxxx <mailto:mytest@xxxxxxxxxxxx>
        <mailto:mytest@xxxxxxxxxxxx <mailto:mytest@xxxxxxxxxxxx>>
                 <mailto:ashley@xxxxxxxxxxxx <mailto:ashley@xxxxxxxxxxxx>

        <mailto:ashley@xxxxxxxxxxxx <mailto:ashley@xxxxxxxxxxxx>>>

                 * ^X-Forwarded-For: kirash4@xxxxxxxxx
        <mailto:kirash4@xxxxxxxxx> <mailto:kirash4@xxxxxxxxx
        <mailto:kirash4@xxxxxxxxx>>
                 <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>
        <mailto:kirash4@xxxxxxxxx <mailto:kirash4@xxxxxxxxx>>>
        mytest@xxxxxxxxxx <mailto:mytest@xxxxxxxxxx> <mailto:mytest@xxxxxxxxxx

        <mailto:mytest@xxxxxxxxxx>> <mailto:ashley@xxxxxxxxxx
        <mailto:ashley@xxxxxxxxxx>

                 <mailto:ashley@xxxxxxxxxx <mailto:ashley@xxxxxxxxxx>>>
                 ! salesdept@xxxxxxxxxx <mailto:salesdept@xxxxxxxxxx>
        <mailto:salesdept@xxxxxxxxxx <mailto:salesdept@xxxxxxxxxx>>
                 <mailto:salesdept@xxxxxxxxxx <mailto:salesdept@xxxxxxxxxx>
        <mailto:salesdept@xxxxxxxxxx <mailto:salesdept@xxxxxxxxxx>>>



             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.

             {^_^}


             --
             users mailing list
        users@xxxxxxxxxxxxxxxxxxxxxxx <mailto:users@lists.fedoraproject.org>
        <mailto:users@lists.__fedoraproject.org

        <mailto:users@lists.fedoraproject.org>>

             To unsubscribe or change subscription options:
        https://admin.fedoraproject.____org/mailman/listinfo/users

             <https://admin.fedoraproject.__org/mailman/listinfo/users
        <https://admin.fedoraproject.org/mailman/listinfo/users>>
             Guidelines:
        http://fedoraproject.org/wiki/____Mailing_list_guidelines
        <http://fedoraproject.org/wiki/__Mailing_list_guidelines>

             <http://fedoraproject.org/__wiki/Mailing_list_guidelines

        <http://fedoraproject.org/wiki/Mailing_list_guidelines>>
             Have a question? Ask away: http://ask.fedoraproject.org




    --
    users mailing list
    users@xxxxxxxxxxxxxxxxxxxxxxx <mailto:users@lists.fedoraproject.org>
    To unsubscribe or change subscription options:
    https://admin.fedoraproject.__org/mailman/listinfo/users
    <https://admin.fedoraproject.org/mailman/listinfo/users>
    Guidelines: http://fedoraproject.org/wiki/__Mailing_list_guidelines
    <http://fedoraproject.org/wiki/Mailing_list_guidelines>
    Have a question? Ask away: http://ask.fedoraproject.org




--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux