procmail
[Top] [All Lists]

Re: Help

1998-07-04 05:04:23
On Sat, 4 Jul 1998 12:11:50 +0100 (BST), Natu Mwamba
<lex4nm1(_at_)unix(_dot_)ccc(_dot_)nottingham(_dot_)ac(_dot_)uk> wrote:
I want to reply message by addressing person's name when I am on vacation.
I have use vacation command, but it doesnot work.

The normal vacation(1) program found on most systems doesn't let you
include the recipient's name in your reply text anywhere, no. Is that
what you want? 

Procmail is a bit of a hassle to use as an autoresponder if you don't
want its other filtering capabilities and it's not easy to get exactly
the same behavior as with stock vacation(1). (Specifically, if you
want to respond to the same address no more than once a month but not
much less either, you're pretty much on your own. Eli the Bearded's
hashd might be worth a look if you really want this.)

However, Procmail does let you customize every part of the
autoresponse because you're free to use whatever shell commands you
have access to (including your own Perl or awk scripts) to construct
the reply. Here's a simplistic version which will replace the literal
string $SUBJECT in your $HOME/.vacation.msg with the original subject,
and $YOU with the correspondent's full name, if available (otherwise
usually her or his e-mail address).

The grabbing of YOU is simplistic and not very elegant but this should
at least hopefully work as a nudge in the right direction. (The rest
of the recipe is more or less something I used myself at some point.)

    ME=lex4nm1(_at_)unix(_dot_)ccc(_dot_)nottingham(_dot_)ac(_dot_)uk
    YOU=`formail -XFrom: | sed -e 's/\([^<]*\)<[^<>]>[  ]*$/\1/'`

    :0whc:vacation.lock
    *   $ ^TO($\ME)\>
    * ! ^FROM_DAEMON
    * ! $ ^X-Loop: $\ME
    *   ? test -r $HOME/.vacation.msg
    * ! ? formail -rD 8192 $HOME/procmail/vacation.cache
    *   ^Subject:[      ]*(\<*Re:?)*[   ]*\/([^r        :]|r[^e]|re[^: ])?.*
    | ( formail -r -A "Precedence: junk" -A "X-Loop: $ME" \
                -I "From: Natu Mwamba (autoresponder) <$ME>" \
                -I "Subject: Automatic reply Re: $MATCH" ; \
      sed -e 's/\$SUBJECT/'"$MATCH"/ -e 's/\$YOU/"$YOU"/ $HOME/.vacation.msg ) \
      | $SENDMAIL $SENDMAILFLAGS -t

The YOU grabber assumes that the original From: header looks like

  From: Real Name <rname(_at_)host(_dot_)domain(_dot_)net>

and doesn't even try to cope with some other frequently seen variants:

  From: "Real Name" <rname(_at_)host(_dot_)domain(_dot_)net>
  From: rname(_at_)host(_dot_)domain(_dot_)net
  From: rname(_at_)host(_dot_)domain(_dot_)net (Real Name)

Some helpful Microsoft software appears to insist on something like 

  From: "'Real Name' <rname(_at_)host(_dot_)domain(_dot_)net>" 
<rname(_at_)host(_dot_)domain(_dot_)net>

(I'm not sure I catch all the nuances here; this is from memory.)

Personally, I wouldn't waste time on implementing this feature. The
To: line already says unambiguously who the response is for.
(Similarly, I think autoresponders should always preserve the original
Subject in the Subject line, or perhaps not even mess with the Subject
at all.)

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

<Prev in Thread] Current Thread [Next in Thread>