procmail
[Top] [All Lists]

Re: Problems with $FROM header

1996-08-14 16:56:10
    > Huh? This is a procmail script, not a shell script. Get rid of
    > this line.

    > > #!/bin/sh

    > Okey Doke.  Early on I was told by someoneelse I needed it.

Only if it is a "/bin/sh" script.  /bin/sh cannot run a procmail recipe
file; only procmail can do that.  If you really wish to make this an
executable file, then place the path to procmail in it.  But, it is not
needed, and you most likely will never run it as a command directly.

    > I guess I don't understand the matching rules.  If I wanted to match all
    > mail coming from a group of machines (regardless who sent it), all named
    > uscsoftn.hsc.usc.edu (where n is one or more digits), could I use:
    >         :0
    >         * $ $FROM(uscsoft)
    > or would I need:
    >         :0
    >         * $ $FROM(.*uscsoft.*)

The definition of $FROM (from my headers.rc) matches characters up to a
non-alphanumeric character, if any.  So, the first '.*' is wrong,
because it will allow a match of the address "notuscsoftware", which is
probably not what you want.

The second, trailing ".*" is also unecessary, since after the last
pattern match is successful, it is okay to still have unmatched
characters in the buffer (unless the last match is "^^" or "$" -- see
the procmailrc man page).

To make sure that there is no trailing part of an address (so that
"uscsoft" does not match "uscsoftball", use a pattern like this:

    :0
    * $ $FROM(uscsoft)$POST_ADDR_SPAN

where $POST_ADDR_SPAN is from my headers.rc file:

    # Use POST_ADDR_SPAN after any names; it will span a string of non-address
    POST_ADDR_SPAN='(([^).!:a-z0-9][-_a-z0-9]*)?[%@>\t 
][^<)]*(\(.*\).*)?)?$([^>]|$))'

If you prefer a less baroque pattern, just do this:

    :0
    * $ $FROM(uscsoft)($|[(_at_)%>, \t])

which should cover *most* of the normal addressing cases.

    > > Another way, though is:
    > >
    > > :0 fh
    > > * $$FROM(jdoe(_at_)nowhere(_dot_)com)
    > > | formail -A "X-Loop: $HERE"
    > >
    > > :0a
    > > ! -oi $THERE
    >   ^^^^^^^^^^^^--Didn't know I could do this.  I had problems with 
$SENDMAIL
    > when I first set things up, so I just started calling sendmail directly.
    > Do I need to set $SENDMAIL & $SENDMAILFLAGS at the top of my .procmailrc,
    > or should they already be set correctly?

If procmail is configured correctly, then SENDMAIL and SENDMAILFLAGS
will be preset for you.  This way, whether your site uses "sendmail",
"mmdf", or "deliver", your recipes won't have to contain this very
site-specific detail.  Just use "SENDMAIL".

Alan

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Problems with $FROM header, Alan Stebbens <stebbens(_at_)anywhere(_dot_)engr(_dot_)sgi(_dot_)com>
    • Re: Problems with $FROM header, Alan Stebbens <stebbens(_at_)anywhere(_dot_)engr(_dot_)sgi(_dot_)com> <=