[news.sysadmin] autoreply - How to ???

bjorn@sysadm.UUCP (Bjorn Satdeva) (02/18/89)

I need a good method to set up automagically reply with a preset
messages to incomming mail on a few special accounts.  I had originally
planned to use the "autoreply" from elm, but it seems like it its
directed more towards answering during vacation, etc. than real
automagic reply.  On top of this, it is not working.

I know there is several setups in usenet-land which have this in
place already, and I would really hate to re-invent the wheel.

If you know how to do this, would you be so kind to reply by
email.  I will summarize if there is any interest.

The system here is is SysV without sendmail, but with smail
added.  I am considering adding sendmail to the system, so 
solutions which require sendmail is of interest also.

Thanks.

Bjorn Satdeva
uunet!sysadm!bjorn	/sys/admin, inc.  The Unix System Administration Experts

tom@lakesys.UUCP (Tom Baas) (02/19/89)

In article <138@sysadm.UUCP> bjorn@sysadm.UUCP (Bjorn Satdeva) writes:
>
>I need a good method to set up automagically reply with a preset
>messages to incomming mail on a few special accounts.  I had originally
>planned to use the "autoreply" from elm, but it seems like it its
>directed more towards answering during vacation, etc. than real
>automagic reply.  On top of this, it is not working.
>
>I know there is several setups in usenet-land which have this in
>email. ... 
>
>The system here is is SysV without sendmail, but with smail
>added.  I am considering adding sendmail to the system, so 
>solutions which require sendmail is of interest also.

I have almost the same situation as Bjorn.  I have a Unix pc with elm 2.1
and can not get "autoreply" to work.  

I have smail added to the machine.

I do not know the difference between smail and sendmail.  Nor do I know the
advantages of one over the other.  Nor how to substitute one for the other.
[But I understand David Brierly (....xanth!galaxia!dave) has a version of
sendmail that would fit on my machine.]

I would very much like to be able to have an autoreply set up on my computer.
Be it the "autoreply" that came with "elm" or something that would allow
one to selectively reply.

If anyone could help Bjorn, I would also be interested.

Thanks

Tom Baas  (...lakesys!tom or ....lakesys!tbaas!tom)

fair@Apple.COM (Erik E. Fair) (02/19/89)

#!/bin/sh
#
#	Mail back articles in *.test newsgroups to the sender
#
# Erik E. Fair <ucbvax!fair>
# December 5, 1987 (revised to use domain address)
# March 16, 1986 (revised)
# August 7, 1985
#
tmp=/tmp/bounce$$
libdir=/usr/lib/news
#
# this file contains the mappings from "uucp" names to fully qualified
# internet domain names:
#
gwfile=${libdir}/gw-u-to-i
#
trap "rm -f ${tmp}; exit 0" 0 1 2 3 15
cat > ${tmp} << 'EOF'
This is an automatic echo of your posting to *.test.
We're mailing this back to you by sending to a hacked up version
of the address in the Path: header (we have some simple routines
in awk to do that), and to the domain address in the From: header
(if the top level domain isn't ".UUCP"). I hope your domain name
is registered so that this will work.

	NNTP service with a :-)

	Erik E. Fair	ucbvax!usenet	usenet@ucbvax.berkeley.edu

EOF
cat >> ${tmp}
#
#	Do it all on one command line...
#
/usr/ucb/Mail -s "Automatic Test Echo" `
(
	echo '@@UUNAME'
	uuname
	if [ -f ${gwfile} ] ; then
		cat ${gwfile}
	fi
	echo '@@END'
	cat ${tmp}
) | awk -e '
BEGIN{
	uuinput	= 0;
	addr	= "";
}
# Some state changes
/^@@UUNAME/	{ uuinput = 1; next; }
/^@@END/	{ uuinput = 0; next; }
#
{
#
# suck in uuname output for path optimization
#
	if (uuinput) {
		if (NF == 1) Lsys[$1] = 1;
		if (NF == 2) gateway[$1] = $2;
		next;
	}
}
/^From:/{
	n = split($2, address, "@");
	if (n != 2) next;
	hostname = address[2];
	n = split(hostname, domain, ".");
	if (n > 1 && domain[n] != "UUCP" && domain[n] != "uucp")
		print $2;
	next;
}
/^Path:/{
#
# This is where we get a return address from. Do path slicing to shorten it.
# One day we will run pathparse and generate something reasonable.
#
	start = 1;
	altgate = 0;
	n = split($2, path, "!");
	if (n == 2) {
		addr = path[2];
		print addr;
		next;
	}
	for(i = 1; i < n; i++) {
		if (Lsys[path[i]]) start = i;
		if (gateway[path[i]]) altgate = i;
	}
#
# To shorten things further, we recognize other internet gateways to UUCP
# and abuse their good names in return addresses too...
#
	if (altgate < start) {
		addr = path[start];
		for(i = start + 1; i <= n; i++) {
			addr = addr "!" path[i];
		}
	} else {
		rmthost = gateway[path[altgate]];
		altgate++;
		if (altgate == n) {
			addr = path[n] "@" rmthost;
		} else {
			addr = path[altgate];
			for(i = altgate + 1; i <= n; i++) {
				addr = addr "!" path[i];
			}
			addr = addr "@" rmthost;
		}
	}
#
#	Hell and damnation. Why are decwrl and psuecl putting "@" in Path?
#
	n = split(addr, parts, "@");
	if (n > 2) {
		addr = parts[1];
		for(i = 2; i < n; i++) {
			addr = addr "%" parts[i];
		}
		addr = addr "@" parts[n];
	}
	print addr;
	next;
}'` < ${tmp}

chip@ateng.ateng.com (Chip Salzenberg) (02/21/89)

According to bjorn@sysadm.UUCP (Bjorn Satdeva):
>I need a good method to set up automagically reply with a preset
>messages to incomming mail on a few special accounts.
>
>The system here is is SysV without sendmail, but with smail added.

The "deliver" program, recently posted to comp.sources.unix and currently
at patchlevel eight, should be able to handle this.

For example, this user delivery file not only delivers messages normally,
it also replies automatically to all messages originating off-site.

	# User delivery file for auto-reply.

	echo "$1"               # Always deliver normally

	case $SENDER in
	*!*)
		mail $SENDER <<-EOF
			Subject: Automatic reply
			To: $SENDER

			This is an automatic reply.  Blah, blah.
		EOF
		;;
	esac
-- 
Chip Salzenberg             <chip@ateng.com> or <uunet!ateng!chip>
A T Engineering             Me?  Speak for my company?  Surely you jest!
	  "It's no good.  They're tapping the lines."

ka@june.cs.washington.edu (Kenneth Almquist) (02/25/89)

chip@ateng.ateng.com (Chip Salzenberg) writes:
> According to bjorn@sysadm.UUCP (Bjorn Satdeva):
>> I need a good method to set up automagically reply with a preset
>> messages to incomming mail on a few special accounts.
>
> The "deliver" program, recently posted to comp.sources.unix and currently
> at patchlevel eight, should be able to handle this.
>
> [Chip then gives a sample user delivery file.]

The proposed script has the problem that it blindly replies to any mail,
and can thus get into an infinite loop if a mailer problems develop or if
someone else is running the same script.  A simple fix is to only reply
to the *first* piece of mail from an individual:

	# User delivery file for auto-reply.

	autoreply=/u/myname/autoreply

	echo "$1"               # Always deliver normally

	case $SENDER in
	*!*)
		if fgrep -x "$SENDER" $autoreply > /dev/null 2>&1
		then	:
		else	mail "$SENDER" <<-EOF
				Subject: Automatic reply
				To: $SENDER

				This is an automatic reply.  Blah, blah.
			EOF
			echo "$SENDER" >> $autoreply
		;;
	esac

Kenneth Almquist