From: heiner@amross.cpr.sub.org (Heinrich Kordewiner)
Newsgroups: alt.sys.amiga.uucp,alt.sys.amiga.uucp.patches
Subject: Re: Mail answering program wanted
Date: 22 Aug 92 21:27:09 GMT
Reply-To: heiner@amross.cpr.sub.org
Followup-To: alt.sys.amiga.uucp
Organization: Private
X-NewsSoftware: GRn 1.16e (7/4/92) by Mike Schwartz & Michael B. Smith

In article <4538.1908922219@brewhq.swb.de> CB@brewhq.swb.de (Christian Balzer) writes:
> In article <ralle.04fq@oberon.dinoco.de> ralle@oberon.dinoco.de (Ralph Niere) writes:
> >
> >Hello net.folks,
> >
> >I'm looking for a program that answers my mail while I'm on vacation.
> >It should send a reply to each incoming mail including a short message
> >telling the sender of the original mail when I'll be back and so on.
> >
>
> If you have AREXX, use this:

Okay, this is my one:

-----------------------------------cut-here------------------------------------
/*

        $VER: vacation.rexx 1.1 (22.08.92)

        (c) 1992 by Heiner Kordewiner (heiner@amross.cpr.sub.org)


        Installation:

          Copy this script to <rexx:vaction.rexx>

          Add a line to Your <uulib:aliases> like

          "heiner: \heiner, |rexx:vacation.rexx"


          When You go on vacations, just type:

          setenv vacation "I will be back on 1st of december"


          After arriving back home, delete this file:

          unsetenv vacation


          A copy of the vacaton-response-mail will be sent to your postmaster-
          account, troublechecking is logged via <uuspool:logfile>.


          The script looks for a table, named <env:vacation_noreply>.
          If it exists, vacation.rexx tries to match replyaddresses
          against lines found in that file. Examplefile:

            #   This is a comment
            #   Don't send replies to pseudodomain <.uucp>
            #
            .uucp
            #
            #   Don't reply to <fido.org> - addresses
            #
            .fido.org
            #
            #   No mail to user@xyz.uvw
            #
            user@xyz.uvw
            #


*/


localonly=0   /* You should change this to "localonly=1" for local testing */



logfile='uuspool:LOGFILE'
temp='t:vacation.'time(s)
dn='VACATION-DAEMON'
pm='postmaster'
from=''
replyto=''
sender=''
subject=''
messageid=''
node=''
domain=''
realname=''
if ~show('L','rexxsupport.library') then do
  if ~addlib('rexxsupport.library',0,-30,0) then do
    call getout('rexxsupport.library not available')
  end
end
if ~exists('env:vacation') then getout('')
if ~(open(cfg,"uulib:config",r)) then do
  call getout("could not open <uulib:config>")
end
do while ~eof(cfg)
  line=readln(cfg)
  parse var line key cont
  select
    when upper(key)="NODENAME" then node=strip(cont)
    when upper(key)="DOMAINNAME" then domain=strip(cont)
    when upper(key)="REALNAME" then realname=strip(cont)
    otherwise nop
  end
end
call close(cfg)
if exists('env:realname') then do
  if ~open(cfg,'env:realname',r) then do
    call getout('could not read <env:realname>')
  end
  else do
    parse var line realname
    call close(cfg)
  end
end
if (node='') then call getout("no NodeName available")
if (domain='') then call getout("no DomainName available")
if (realname='') then call getout("no RealName available")
parse pull line
if (pos('!',word(line,2))=0) then call getout('')  /* prevent local loops */
do while (~eof(STDIN) & line ~= '')
  if eof(STDIN) then break
  parse var line key cont
  select
    when upper(key) = 'FROM:' & from = '' then from = strip(cont)
    when upper(key) = 'REPLY-TO:' & replyto = '' then replyto = strip(cont)
    when upper(key) = 'SUBJECT:' & subject = '' then subject = strip(cont)
    when upper(key) = 'MESSAGE-ID:' & messageid = '' then messageid = strip(cont)
    when upper(key) = 'SENDER:' & sender = '' then sender = strip(cont)
    otherwise nop
  end
  line=readln(STDIN)
end
if replyto ~= '' then from=replyto
if (from='') then do
  if (sender='') then do
    call getout('Obsure mailheader, no <From:> or <Sender:>')
  end
  else do
    call getout('no <From:> or <Reply-To:>, no mail to 'sender)
  end
end
if (pos('DAEMON',upper(from))>0) then
  call getout("Daemon? No mail sent to "from)
from=word(from,1)
if (pos('-',word(translate(from,' ','@'),1))>0) then
  call getout("Mailinglist? No mail sent to "from)
if (pos('POSTMASTER',upper(from))=1) then
  call getout("Postmaster-Daemon? No mail sent to "from)
if (pos('!',from)>0) then
  call getout("<!> in address, no mail sent to "from)
if (pos(':',from)>0) then
  call getout("<:> in address, no mail sent to "from)
if (pos('%',from)>0) then
  call getout("<%> in address, no mail sent to "from)
if (pos('@',from)=1) then
  call getout("Leading <@> in address, no mail sent to "from)
if (lastpos('.',from)<pos('@',from)) then
  call getout("No domain available, no mail sent to "from)
if (messageid='') then
  call getout('obsure mailheader, no <Message-ID:>')
if exists('env:vacation_noreply') then do
  if ~(open(cfg,'env:vacation_noreply',r)) then do
    call getout('could not read <env:vacation_noreply>')
  end
  do while ~eof(cfg)
    line=upper(strip(readln(cfg)))
    if ~(pos('#',line)=0) && ~(line='') then do
      if (lastpos(line,upper(from))=(length(from)-length(line)+1)) then do
        call close(cfg)
        call getout('Address matched <'line'>, no mail to 'from)
      end
    end
  end
  call close(cfg)
end

if(~open(mail,temp,w)) then call getout("could not write "temp)
call writeln(mail,'In-Reply-To: 'messageid)
if (subject ~= '') then do
  parse var subject key cont
  if (upper(key)='RE: ') then subject=cont
  call writeln(mail,'Subject: Re: 'subject)
end
else do
  call writeln(mail,'Subject: Mail 'messageid' arrived at 'node||domain)
end
call writeln(mail,'')
call writeln(mail,dn' answering:')
call writeln(mail,'')
call writeln(mail,'Site 'node||domain' received Your mail 'messageid)
call writeln(mail,'at 'date()' 'time()'. Maybe it will take some days until you get an answer')
call writeln(mail,'because 'realname' is not attainable.')
call writeln(mail,'')
if open(vac,"env:vacation") then do
  do while ~eof(vac)
    line=readln(vac)
    call writeln(mail,line)
  end
end
call writeln(mail,'Few lines from Your mail are following:')
cnt=0
do while (~eof(STDIN) & (cnt < 8))
  line=readln(STDIN)
  call writeln(mail,'>'line)
  cnt=cnt+1
end
call close(mail)
if ~(localonly) then do
  address COMMAND 'sendmail <'temp' -t 'from' -f 'pm' -R 'dn' -b 'pm
end
else do
  address COMMAND 'echo >>'temp' "*nDEBUG: Got replyaddress 'from'"'
  address COMMAND 'sendmail <'temp' -t 'pm' -f 'pm' -R 'dn
end
address COMMAND 'delete >nil: 'temp
call getout('response sent to 'from)

getout:
parse arg mess
if ~(mess='') then do
  if (localonly) then mess='DEBUG: '||mess
  if ~exists(logfile) then do
    call Open(log,logfile,w)
  end
  else do
    do while ~Open(log,logfile,a)
      call delay(50)
    end
  end
  if localonly then say(mess)
  call writeln(log,"("left(date(usa),5)"-"time()") -,-,- vacation, "mess)
  call close(log)
end
call remlib('rexxsupport.library')
exit 0

-----------------------------------cut-here------------------------------------

Have fun

Heiner

--
H. Kordewiner, Schuetzenpfuhl 5, D-3572 Amoeneburg 3, heiner@amross.cpr.sub.org