Subject: Re: Script for users auto-reply when gone

From: [email-masked] (Stephen R. van den Berg)
Date: Wed, 7 Sep 1994 18:54:06 +0200

Eric C Hagberg <[email-masked]> wrote:
>I think I saw a posting here a while back, about a script that you could
>alias users that have left or no longer have accounts towards, and get
>auto-responses that would inform the senders of mail to those address that
>the person has left, or whatever.

If you're using sendmail v8.* you can probably make use of the
REDIRECT alias feature.

I.e. enter aliases of the form:

joe:	[email-masked]

-- 
Sincerely,                                  [email-masked]
           Stephen R. van den Berg (AKA BuGless).

This sentance contains threee errors.

---

From: Adam Shostack <[email-masked]>
Date: Wed, 7 Sep 94 13:10:42 EDT

Stephan R. van den Berg:

| Eric C Hagberg <[email-masked]> wrote:
| >I think I saw a posting here a while back, about a script that you could
| >alias users that have left or no longer have accounts towards, and get

| If you're using sendmail v8.* you can probably make use of the
| REDIRECT alias feature.
| 
| I.e. enter aliases of the form:
| 
| joe:	[email-masked]

We played with this feature, found it to be insufficient.  The bounce
message you get from the mailer daemon does not do a good job of
directing your eyes towords the pertinent information.  It looks like
all the rest of sendmail generated bounces.  Instead, we simply
forward mail forever.  We would like a nice reprocessor, but the
sendmail one generated way, way too much confusion.

Adam

---

From: "J. Daniel Smith" <[email-masked]>
Date: Wed, 7 Sep 94 13:24:29 -0400

Eric C Hagberg ([email-masked]) writes on  7 September 1994 at 12:40:04 -0400
>I can't seem to find it now, and would really appreciate getting a copy of it.

Here's something I put together a while back...

The alias file should have entries like:
   joe: "|/usr/local/bin/procmail \
         USER=joe FORWARD=[email-masked] \
	 /etc/mail/not_here"

   Dan
====================== message is author's opinion only ======================
J. Daniel Smith         Bristol Technology Inc., Ridgefield, Connecticut (USA)
[email-masked]         (203) 438-6969, 438-5013 (FAX)            
                        FTP: ftp.bristol.com     WWW: http://www.bristol.com
                                --------
 Gott ist mit uns am Abend und am Morgen, und ganz gewiss an jedem neuen Tag.
	- Dietrich Bonhoeffer
-----
# 
# J. Daniel Smith
# 18 April 1993
#
# ~/.procmailrc file to process mail for users that are no longer at
# Applicon.
#   * bounce the message back to the sender telling them user is no
#     longer here and give forwarding address
#   * forward message onto recipient using new address with a comment
#     telling them is passed through Applicon

PATH=/bin:/usr/bin:/usr/local/bin
SHELL=/bin/sh

# log everything verbosely, since I want to see how all this works
LOGFILE=/etc/mail/LOG
VERBOSE=on

# cause procmail to exit with exit code 67 = EX_NOUSER; this will make
# sendmail bounce the message   
TRAP="exit 67;"

##### THIS MUST BE THE FIRST RECIPIE
# Add an X-Forward-To: header to the mail message so that later
# recipies can check the forwarding address.
# Also be sure there is a Subject: line in the message
##### THIS MUST BE THE FIRST RECIPIE
:0hf
| formail -i "X-Forward-To: ${FORWARD}" -a "Subject: No subject given!"

# find intereseting header lines
FROM=`formail -xFrom:`
TO=`formail -xTo:`
CC=`formail -xCc:`
SUBJECT=`formail -xSubject:`
DATE=`formail -xDate:`

# get the date in RFC822 format for insertion into some messages;
# the "Resent-Date:" field is copied from the "Date:" field on some systems.
# RFC1123 says "All mail software SHOULD use 4-digit years in dates..."
RESENT_DATE=`date '+%a, %d %h %Y %H:%M:%S %Z'`

# The domain to check against for mail forwarding.  This is used to
# prevent mail messages that may contain confidential information from
# being automatically forwarded onto the forwarding address.
#
# If mail originates from within ${DOMAIN} and the forwarding
# address is outside of ${DOMAIN}, then the message WILL NOT be
# forwarded on.  Mail originating outside of ${DOMAIN} can be
# forwarded anywhere, and if the forwarding address is also within
# ${DOMAIN}, then all messages can be forwarded on.
DOMAIN=slb.com

# several sub-domains could exist in ${DOMAIN}.  This is our
# fully-qualified domain name
FQDN=ann-arbor.applicon.${DOMAIN}

# USER is set on the command line from the sendmail aliases file when
# procmail is invoked.  Since messages likely will be sent off-site,
# we want to only use a fully-qualified address.
ADDRESS=${USER}@${FQDN}

#
# forward the message onto the new address if its OK.  Remove the
# X-Forward-To: line we just added above if the message is resent.
# Also, add various Resent-* headers to the forwarded message and
# change the Subject: line so the recipient will know it passed through
# our system.

# mail from outside may be forwarded anywhere
:0hf
* $!^From:${ADDRESS}
* $!^From:.*\.${DOMAIN}
* ^X-Forward-To: .
| formail -i "X-Forwarding-Ok: YES"
# anything may be forwarded within domain, but we already handled mail
# from outside above 
:0hf
* $!^From:${ADDRESS}
* $^From:.*\.${DOMAIN}
* $^X-Forward-To:.*\.${DOMAIN}
| formail -i "X-Forwarding-Ok: YES"

:0c
* ^X-Forwarding-Ok: YES$
|formail -I "Subject:$SUBJECT [Forwarded from: $ADDRESS]" \
         -i "Resent-To: $FORWARD" \
	 -i "Resent-From: $ADDRESS" \
	 -i "Resent-Date: $RESENT_DATE" \
	 -IX-Forward-To: -IX-Forwarding-Ok: \
 | $SENDMAIL -oi $FORWARD
#
# Use the regexp from the previous recipe to set an environment
# variable indicating if messages can be forwarded.  This is used below
# to tailer the message sent back to the original sender.
FWD_OK="NO"
:Ac
FWD_OK=|echo "YES"

# "bounce" a message back saying this addressee has moved on.
# Carbon copy the forwarded address and the local postmaster.
# Add a "Precedence: bulk" header line to keep programs like
# vacation(1) from trying to respond to this message.
:0h
* $!^From: ${ADDRESS}
|(formail -r \
          -I "Subject: your mail to \"$TO\"" \
          -I "From: Postmaster@${FQDN}" \
	  -I "Precedence: bulk" \
          -A "CC: $FORWARD, Postmaster@${FQDN}" ;\
  echo "Mail can no longer be delivered locally to: $ADDRESS" ;\
  echo "" ;\
  echo "Your message of: $DATE" ;\
  echo "Sent to: $TO" ;\
  if [ "$CC" != "" ]; then \
    echo "Carbon copies to: $CC" ;\
  fi ;\
  echo "Regarding: $SUBJECT" ;\
  if [ "$FWD_OK" = "YES" ]; then \
    echo "Has been forwared onto $FORWARD" ;\
  else \
    echo "Has been bounced back to the originator." ;\
    if [ "$FORWARD" != "" ]; then \
      echo "Mail originating within the \"$DOMAIN\" domain can not be" ;\
      echo "automatically forwarded outside of Schlumberger." ;\
    else \
      echo "No forwarding address is available for $ADDRESS" ;\
    fi ;\
  fi ;\
  echo "" ;\
  if [ "$FORWARD" != "" ]; then \
    echo "Please direct all future correspondence to this addressee's" ;\
    echo "new address of: $FORWARD" ;\
    echo "" ;\
  fi; \
  echo "If you maintain a mailing list, please determine if" ;\
  echo "$ADDRESS (or some form of \"$USER\") can be" ;\
  if [ "$FORWARD" != "" ]; then \
    echo "be changed to the new address shown above." ;\
  else \
    echo "removed from it." ;\
  fi ;\
  echo ""; echo "" ;\
  echo "This message was generated automatically by a \"procmail\" script" ;\
  echo "on the machine aamail.$FQDN located at" ;\
  echo "Applicon, Inc. in Ann Arbor, MI, USA.  Questions regarding this" ;\
  echo "message itself should be sent to:" ;\
  echo "   Postmaster@$FQDN" ) \
  | $SENDMAIL -t

# pitch anything that gets through to here; we don't want it
# ending up in somebody's mailbox
:0
/dev/null