Subject: Re: How Do I Autorespond to Specific Senders?

From: [email-masked] (Hans-Albert Schneider)
Date: Tue, 19 Apr 1994 14:39:27 +0200

On Apr 13,  6:55pm, James R Buck wrote
on subject "How Do I Autorespond to Specific Senders?"
} 
} How do I respond to specific users via the .procmailrc file?
}  

I am doing something like this for two reasons: first, to
auto-reply to test mails, second, to auto-acknowledge mail from
certain senders. It probably does not fit exactly for your
needs, but it should be a good starting point.

# Auto-Reply to test messages
# Test	1: Mail is addressed to me.
#	2: Subject contains word starting with "test" (includes
#	   "testing", "tester", but not "latest").
#	3: Mail is not a reply (Subject does not contain "Re:",
#	   "Re^2:", "AW:" (German version of Microsoft-Mail)).
:0
* ^TO(has@|Hans.Albert.Schneider)
* ^Subject:.*[^a-z]Test
* !^Subject:[	 ]*(Re(\^[0-9]*)?|AW):
{
	:0c
	| replyTest

	:0fh
	| formail -A "X-Auto-Replied: $DATE ($hostname)"
}

# Auto-Reply to certain senders
#	1: Mail is addressed to me.
#	2: Mail comes from Some.Dom.Ain
#	3: Mail does not come from a daemon.
:0
* ^TO(has@|Hans.Albert.Schneider)
* ^From:.*Some\.Dom\.Ain
* !^From:.*MAILER-?DAEMON
{
	:0 h
	LOG=| autoack

	:0fh
	| formail -A "X-Auto-Acknowledged: $DATE ($hostname)"
}

Here are the replyTest and autoack scripts:

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to [email-masked] if you want that tool.
# Contents:  autoack replyTest
# Wrapped by has@borel on Tue Apr 19 14:23:16 1994
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo '          "shar: End of archive."'
if test -f 'autoack' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'autoack'\"
else
  echo shar: Extracting \"'autoack'\" \(510 characters\)
  sed "s/^X//" >'autoack' <<'END_OF_FILE'
X#!/bin/sh
X#	send automatic acknowledgement
Xtmp=$HOME/tmp/mail.$$
Xhost=`hostname`
Xdate=`date`
X
X# bcc="-A 'Bcc: $USER'"
Xbcc=""
X
X(
Xtee $tmp | \
X	formail -rt $bcc \
X		-A "X-Loop: ${USER}@${host}: acknowledged $date"
X
Xcat <<EOF
XDear mail partner:
X
XThis is an automated acknowledgement of your mail. I have attached the
Xheader below for you to identify it.
X
XYours,
X	Hans-Albert Schneider
X
XEOF
X
Xsed -e 's:^:> :' < $tmp
X
X) | /usr/lib/sendmail -t
Xrc=$?
X
Xecho "auto-acknowledged $date ($host)"
Xecho ""
X
Xrm $tmp
Xexit $rc
END_OF_FILE
  if test 510 -ne `wc -c <'autoack'`; then
    echo shar: \"'autoack'\" unpacked with wrong size!
  fi
  chmod +x 'autoack'
  # end of 'autoack'
fi
if test -f 'replyTest' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'replyTest'\"
else
  echo shar: Extracting \"'replyTest'\" \(458 characters\)
  sed "s/^X//" >'replyTest' <<'END_OF_FILE'
X#! /bin/sh
X# Autoreply to a (test) message including the whole message
X
Xtmp=$HOME/tmp/mail.$$
Xreply=$tmp.reply
X
Xcat - > $tmp
X
Xformail -rt -A "Bcc: $USER" < $tmp > $reply
X
Xcat << EOF >> $reply
X
XDear mail partner:
X
XThis is an automated reply. Assuming you are testing something, I have
Xincluded your message below.
X
XYours sincerely,
X	Hans-Albert Schneider
X
XEOF
X
Xsed -e 's:^:> :' < $tmp >> $reply
X
X/usr/lib/sendmail -t < $reply
X
Xrc=$?
X
Xrm $tmp $reply
X
Xexit $rc
END_OF_FILE
  if test 458 -ne `wc -c <'replyTest'`; then
    echo shar: \"'replyTest'\" unpacked with wrong size!
  fi
  chmod +x 'replyTest'
  # end of 'replyTest'
fi
echo shar: End of archive.
exit 0

--
Hans-Albert Schneider		<[email-masked]>
Siemens AG				phone:	(+49) 89 636 45445
Corporate Research and Development	fax:	(+49) 89 636 42284
Munich, Germany
 -- To get my PGP key, send me a mail with subject "send key" --