home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
pop
/
!POP
/
NB055pre
/
POP
/
sendmail
(
.txt
)
< prev
Wrap
RISC OS BBC BASIC V Source
|
1995-07-13
|
6KB
|
260 lines
>SendMail
takes a mail message file and copies to outgoing directory
** Kludged for !POP mail transport
" at line ";
"OS_GetEnv"
ver$="0.55"
cf$="":file$="":test%=
getpar(A$," ")
"-c":cf$=
getpar(A$," ")
"-test":test%=
A$=""
cf$=""
exit(1,"No control file parameter")
checkdirs
tmp%300,nbuf%4096
no fixed upper limit, let memory be the factor...
tomax%=(
-1000)
to$(tomax%)
>gate$=
varval("NewsBase$RemoteHost"):
gate$<5
gate$=""
** Following changed from host name to mail name for !POP
3localhost$=
lower(
varval("NewsBase$MailName"))
now extract to/from info from control file...
from$="":to$="":count%=0
GC1%=
openin(cf$):
C1%=0
exit(1,"Couldn't open control file "+cf$)
A$=
B$=
getpar(A$,":")
"S":from$=A$
"D":file$=A$
%6
count%<tomax%
to$(count%)=A$:count%+=1
cf(C1%)
from$=""
exit(1,"Couldn't decode sender")
from$,"@")<1
localhost$>""
from$+="@"+localhost$
file$=
dir(cf$)+"."+file$
objtype(file$)<>1
exit(1,"Message file not found "+file$)
test%
"ka9q sendmail "+ver$+" test output: "+file$
"Maximum recipients = ";tomax%
"From: "+from$
"To: "+to$(0)
l%=1
tomax%:
to$(l%)>""
" "+to$(l%)
exit(0,"test run")
now make mqueue.work file...
three choices...
1) multiple recipients, smtp gateway defined; send as one file via gateway
2) single recipient, send direct
3) multiple recipients, no gateway; send separately directly.
count%>1
gate$>""
seq%=
to$=to$(0)
C5 test%=
from$," "):
test%>1 from$=
from$,test%)
D2 o$="<POP$MailDir>.spool.mqueue.work."+
seq%
C%=
openout(o$)
F8
C%=0
exit(1,"Couldn't open output work file")
#C%,gate$
#C%,from$
l%=0
count%-1
J$
to$(l%)>""
#C%,to$(l%)
K
cf(C%):
settype(o$,&FFF)
M2 o$="<POP$MailDir>.spool.mqueue.text."+
seq%
N. F%=
movefile(file$,o$):
settype(o$,&FFF)
exit(1,"Couldn't move to spool area")
l%=0
count%-1
seq%=
to$=to$(l%)
to$>""
at%=
to$,"@",1)+1
V= tosite$=
to$,at%):
at%<1
tosite$=""
tosite$=gate$
WI
tosite$=""
exit(1,"Couldn't send; no destination or gateway")
X9 test%=
from$," "):
test%>1 from$=
from$,test%)
Y6 o$="<POP$MailDir>.spool.mqueue.work."+
seq%
C%=
openout(o$)
[<
C%=0
exit(1,"Couldn't open output work file")
#C%,tosite$
#C%,from$
#C%,to$
_%
cf(C%):
settype(o$,&FFF)
`6 o$="<POP$MailDir>.spool.mqueue.text."+
seq%
a2 F%=
copyfile(file$,o$):
settype(o$,&FFF)
b5
exit(1,"Couldn't move to spool area")
c
F%=
delfile(file$)
finished, so remove source files
"remove "+file$
"remove "+cf$
exit(0,"Mail sent")
movefile(s$,d$)
"XOS_FSControl",25,s$,d$
"XOS_FSControl",26,s$,d$,(1<<7)
copyfile(s$,d$)
"XOS_FSControl",26,s$,d$
delfile(f$)
"XOS_File",6,f$
exit(n%,a$)
("set NewsBase$ReturnCode "+
("set NewsBase$ReturnInfo "+a$)
checkdirs
objtype("<POP$MailDir>")<2
exit(1,"!MailDir not found")
ensuredir("<POP$MailDir>.spool")
ensuredir("<POP$MailDir>.spool.mqueue")
ensuredir("<POP$MailDir>.spool.mqueue.text")
ensuredir("<POP$MailDir>.spool.mqueue.work")
objtype("<POP$MailDir>.spool.mqueue.text")<2
objtype("<POP$MailDir>.spool.mqueue.work")<2
exit(1,"SMTP spool directories not created")
ensuredir(f$)
objtype(f$)
t%<2
"XOS_File",8,f$
sget(h%)
return line from file without error if too long...
a$,C%
C%<>10:C%=
a$<253
C%<>10
C%<>13:a$+=
objtype(f$)
"XOS_File",17,f$
t%;F%
settype(f$,t%)
"XOS_File",18,f$,t%
h%<>0
"XOS_Find",0,h%:h%=0
varval(A$)
L%,F%
"XOS_ReadVarVal",A$,tmp%,256,0,3
,,L%;F%
L%>256
tmp%?L%=13:=$tmp%
lower(A$)
B$,l%,c%,a%,z%,d%
"A":z%=
"Z":d%=
"a"-a%
A$>0
l%=1
c%=
A$,l%,1)
c%>=a%
c%<=z%
c%+=d%
B$+=
read in sequence numer, and update
seq%,C%
.seq$="<POP$MailDir>.spool.mqueue.sequence"
objtype(seq$)=0
seq%=1
objtype("<POP$MailDir>.spool.mqueue.text."+
seq%)>0:seq%+=1:
A C%=
openin(seq$):
C%=0
exit(1,"Can't open sequence file")
" seq%=
#C%):
cf(C%):seq%+=1
openout(seq$):
seq%:
cf(C%)
=seq%
openin(f$)
h%,F%
"XOS_Find",&4F,f$
h%;F%:
1)<>0
h%=0
openup(f$)
h%,F%
"XOS_Find",&CF,f$
h%;F%
"XOS_Find",&8F,f$
h%;F%:
1)<>0
h%=0
openout(f$)
h%,F%
"XOS_Find",&8F,f$
h%;F%:
1)<>0
h%=0
getpar(
A$,s$)
B$,l%
A$,s$)
l%>0
B$=
A$,l%-1):A$=
A$,l%+1)
B$=A$:A$=""
tmpfile
f$="<NewsBase$Data>.scratch.tmp"+
(10000))
objtype(f$)=0
dir(f$)
l%-=1:
f$,l%,1)="."
f$,l%-1)