/*
    Spam-o-matic v1.0
    19.Nov.96 by Kirk Strauser <kstrauser@gxl.com>

    Saves the current message in Thor, and uses YAM to forward the
    message to several "interested" parties.  PLEASE don't use this
    as a toy!  The only way our concerns will be taken seriously
    is if WE take them seriously.
*/

options results
options failat 31

/* Save our current (Thor) AREXX port */
thorport = address()

'savemessage current filename="T:Spam.temp1" overwrite'

yamalreadypresent=1
if ~show('p','YAM') then do
   address command 'Run <>NIL: YAM:YAM'
   address command 'WaitForPort "YAM"'
   yamalreadypresent=0
   end

call open spami,"T:Spam.temp1",r
flag=0

/* Read the file until we find the From: tag */

do while flag=0
   a=readln(spami)
   if eof(spami) then flag=-1
   if upper(left(a,5))="FROM:" then flag=1
   end

/* This SHOULDN'T happen.  But, ya never know. */

if flag=-1 then do
   say "Couldn't find author information."
   exit
   end

parse var a a": "author  /* Parse the author info out of the line */
author=word(author,words(author)) /* We want ONLY the e-mail address */

/* This lines remove any <> around the address,
   i.e. Kirk Strauser <kstrauser@gxl.com> */

if left(author,1)="<" then author=substr(author,2)
if right(author,1)=">" then author=left(author,length(author)-1)

/* Get the domain in a seperate variable */
parse var author j"@"domain

call close spami

/* Build the outgoing message */
address command 'Join YAM:SpamHeader T:Spam.temp1 YAM:SpamFooter as T:spam.temp2'

address 'YAM'
subj = 'Usenet spam/mail fraud'
mailwrite

/* The writesubject line HAS to have this punctuation, as per M. Beck */
'writesubject "Usenet spam/mail fraud"'

/* Send the mail to the author, his postmaster, the Federal Trade Commision,
   and the Bureau of Consumer Services */
writemailto author',postmaster@'domain',bbroder@ftc.gov,nfic@internetmci.com'
writeletter 'T:Spam.temp2'

/* Find out what to do with the finished product */
'request "Should this be sent or queued?" "Send|Queue"'
action=result
if action=1 then writesend
if action=0 then writequeue

/* If we started YAM, we end it */
if ~yamalreadypresent then 'quit'

address command 'Delete >NIL: T:Spam.temp(1|2)'


