home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 25
/
amigaformatcd25.iso
/
websites
/
f1_gp
/
ftp
/
rexx
/
returnreceipt.lha
/
ReturnReceipt.br
next >
Wrap
Text File
|
1997-09-19
|
4KB
|
133 lines
/* $VER: ReturnReceipt.br 1.1 (19.9.97)
**
** Author: Oliver Roberts
** E-Mail: Oliver@poboxes.com
** WWW: http://www.nanunanu.org/~oliver/
**
** Brief Description:
**
** Processes messages with a "Return-Receipt-To: <address>" header line
** and creates an event to the sender confirming the message has been
** received successfully
**
** Should be called via SortMail
*/
/********************* DO NOT MODIFY BELOW HERE *************************/
Usage = 'Usage: ReturnReceipt.br BBSName Conference MessageNo'
options results
/* Strip "'s from arg string and parse into variables */
parse arg CmdLine
CmdLine = compress(CmdLine,'"')
parse var CmdLine bbs conf msgnum
if bbs = '?' | conf = '' | msgnum = '' then do
say 'ReturnReceipt.br: ' || Usage
exit
end
if ~show('p', 'BBSREAD') then do
address command
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
end
address(bbsread)
/* Read the data on the message that is to be forwarded */
READBRMESSAGE bbsname '"'bbs'"' confname '"'conf'"' msgnr msgnum headstem HEADTAGS textstem TEXTTAGS datastem DATATAGS
if(rc ~= 0) then goto quit
/* Find "Return-Receipt-To:" header line */
rrt = ''
do n=1 to TEXTTAGS.COMMENT.COUNT
if (upper(left(TEXTTAGS.COMMENT.n,18)) = upper('Return-Receipt-To:')) then
rrt = SUBSTR(TEXTTAGS.COMMENT.n,19)
end
if (rrt = '') then exit
/* Parse return address */
addresspos = lastpos(' ',rrt,pos('@',rrt))
addresspart = word(substr(rrt,addresspos),1)
toaddress = strip(addresspart,B,' <>')
tofullname = ''
if (words(rrt) > 1) then do
if (addresspos = 1) then do
namepart = substr(rrt,length(addresspart)+1)
end
else do
namepart = substr(rrt,1,addresspos)
end
tofullname = strip(namepart,B,'()" ')
end
/* Get a unique message for the event */
UNIQUEMSGFILE bbsname '"'bbs'"' stem UNIQUEFILE
if(rc ~= 0) then goto quit
/* Create message file */
if(~open(fh, UNIQUEFILE.NAME, W)) then ExitMsg '"Unable to open file:' UNIQUEFILE.NAME
/* Build the message */
TB_WDAYS = 'Monday Tuesday Wednesday Thursday Friday Saturday Sunday'
TB_MONTH = 'January February March April May June July August September October November December'
AMIGA2DATE HEADTAGS.CREATIONDATE stem '"'date'"'
if(date.WDAY == '0') then
WKDays = 'Sunday'
else
WKDays = word(TB_WDAYS, date.WDAY)
MODays = word(TB_MONTH, date.MONTH)
call writeln(fh,'Machine-generated automatic response:')
call writeln(fh,'')
call writeln(fh,'Your message to ' || HEADTAGS.TONAME || ' (' || HEADTAGS.TOADDR || ')')
call writeln(fh,'dated' WKDays date.MDAY MODays date.YEAR 'at' right('0' || date.HOUR,2) || ':' || right('0' || date.MIN,2) || ':' || right('0' || date.SEC,2))
call writeln(fh,'with message-id ' || HEADTAGS.MSGID)
call writeln(fh,'and subject "' || HEADTAGS.SUBJECT || '"')
call writeln(fh,'has been received successfully.')
call writeln(fh,'')
call writeln(fh,'Note: This receipt doesn''t imply that the message has been read.')
call writeln(fh,'')
call writeln(fh,'--')
if ~(open(tv,'ENV:THOR/THORVERSION',R)) then do
call writeln(fh,'THOR - Amiga TCP/IP')
end
else do
call writeln(fh,readln(tv) || ' - Amiga TCP/IP')
call close(tv)
end
call close(fh)
/* Post it */
drop EVENT.
EVENT.SUBJECT = 'RECEIPT: ' || HEADTAGS.SUBJECT
EVENT.TONAME = tofullname
EVENT.TOADDR = toaddress
EVENT.CONFERENCE = conf
EVENT.MSGFILE = UNIQUEFILE.FILEPART
WRITEBREVENT bbsname '"'bbs'"' event 0 stem EVENT
if(rc ~= 0) then goto quit
exit
ExitMsg:
parse arg msgstr
say ''
say 'ReturnReceipt.br:' msgstr
say ''
exit