procmail
[Top] [All Lists]

RE: FROM_DAEMON on preventing loops

2008-09-29 20:52:11
Skip Morrow wrote Sunday, September 28, 2008 1:26 PM:


      I am still looking for an answer to the question below:
how would you write an autoforward rule for this list since
messages from this list trigger the FROM_DAEMON regex?

Before I look down below, I must ask: have you thought about
simply subscribing to this list at the address you want to
receive it at?  Heck, you could subscribe under two addresses,
and use one to answer and the other to receive (and trash
the other receipt if you wanted).

      Also, I have noticed that some of my mails (two so far)
that do get forwarded to my gmail account have the FROM: field
replaced with my hostname instead of the original sender.  The
copy left on my server here still has the correct FROM header.
I have no rules that write anything to the FROM header.  The
logs for those two messages look exactly like the logs for all
the rest of my messages.  Any ideas why something like that
would happen?  Does sendmail just do that sometimes if it sees
something it doesn't like?

Hmm.  Maybe you need to set your server up with some sendmail
option that doesn't translate the sender on forwarding.  I don't
run a server, so I don't know more about that.  Are you sure
you aren't accidentally munging the header somewhere earlier
on in your rcfile?

      :0
      * ^List-Id: discussion of the procmail program


      {
       :0
      
       * !^FROM_DAEMON
       * !^FROM_MAILER
       * !^X-Loop: pelorus.org
       {
       :0fw
      
       | /usr/bin/formail -A "X-Loop: pelorus.org"
      
       :0c
       !skip(_dot_)x(_dot_)mobile(_at_)gmail(_dot_)com
       }
      }
      
      :0
      $DEFAULT
      

Well, without getting too much into what you did, I'll just
post what I would do.  The best field to filter on for the
procmail list is probably the X-BeenThere header.
Also, I wouldn't rely on one single space for the X-Loop snag,
because mail going out somewhere else and coming back could
have whitespace expanded or compressed by various things
beyond your control.  Easiest is to define whitespace somewher
up above for repeat use:

  SPACE = ' '
  TAB = '       '  # a real tab
  WS = $SPACE$TAB


  :0
  * $  ^X-BeenThere:[$WS]*procmail(_at_)lists[(_dot_)]RWTH-Aachen(_dot_)DE
  {
     :0 c
     * $! ^X-Loop:[$WS]*pelorus[.]org
     | formail -A "X-Loop: pelorus.org" |\
       "$SENDMAIL" $SENDMAILFLAGS skip(_dot_)x(_dot_)mobile(_at_)gmail(_dot_)com

     SWITCHRC
  }
 
If you haven't switched rcfiles before this point, the SWITCHRC
should exit procmail and deposit the message in $DEFAULT automatically
whilst applying the proper locking.

If you have switched rcfiles, then the invocation of SWITCHRC simply
returns you to the previous rcfile.  In that case, or if you
prefer in any event, use, instead, your

   :0:
   "$DEFAULT"


Note that I did not put quotes around $SENDMAILFLAGS.  That was
on purpose.  At least in my tests on my system, quotes there
screws up sendmail.

I have tested this.  It works fine for me.

Dallman

____________________________________________________________
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