home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma62.dms / ma62.adf / Voyager10 / Rexx / MailTo-THOR.VRX < prev    next >
Text File  |  1996-05-03  |  6KB  |  197 lines

  1. /* SendMail.thor by Troels Walsted Hansen <troels@stud.cs.uit.no>
  2. ** $VER: SendMail.thor v1.10 (27.12.95)
  3. **
  4. ** Now change the two variables below to whatever fits for your setup.
  5. ** MailSystem is the name of your TCP/SOUP/UUCP/whatever email system in
  6. ** THOR, and MailConfName is obviously the name of your email conference in
  7. ** THOR.
  8. **
  9. ** Setting AddSignature to 'Yes' will make SendMail.thor read your conference/
  10. ** BBS/global signature settings and add that signature to your mails.
  11. **
  12. ** Note: THOR does not have to be running for this script to work!
  13. **
  14. ** History:
  15. ** ¯¯¯¯¯¯¯¯
  16. ** SendMail.thor v1.00 (07.08.95)
  17. **  · First release.
  18. **
  19. ** SendMail.thor v1.10 (27.12.95)
  20. **  · Now optionally appends signature configured in THOR to the email.
  21. **  · Updated my email address :-)
  22. **  · Implemented previously non-existant errorchecking and reporting
  23. **
  24. ** SendMail.thor v1.11 (24.04.96)
  25. **  . Work with the browser Voyager by Olli Wagner
  26. **  . Add 'SendEvent' variable to automatically send the e-mail, if needed.
  27. **
  28. ** Modified by Eric Giroux (ericgir@cam.org) for Voyager.
  29. ** MUI's built-in arexx command INFO is used to determine the public
  30. ** screen.
  31. **
  32. ** In SETTINGS/NETWORK/Mailto: app
  33. ** Enter {path}rx {path}Mailto-Thor.VRX  %h
  34. **
  35. */
  36. options results
  37.  
  38. CmdPath    = 'Thor:bin/'        /* Path to SendTCP and GetTCP */
  39. MailServer = 'POP.HIP.CAM.ORG'  /* Your mail server */
  40. NewsServer = 'NNTP.HIP.CAM.ORG' /* Your news server */
  41. NumSockets = 4                  /* The number of sockets for Thor to use (1-4) */
  42. SendEvent  = "Y"                /* Y to send event automatically or N for doing it manually */
  43. MailSystem = 'News&Mail'
  44. MailConfName = 'EMail'
  45. AddSignature = 'Yes'
  46.  
  47. call pubscreen()
  48.  
  49. /* DON'T CHANGE ANYTHING BELOW HERE */
  50.  
  51. if ~show('p', 'BBSREAD') then do
  52.     address command
  53.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  54.         "WaitForPort BBSREAD"
  55. end
  56.  
  57. address(BBSREAD)
  58.  
  59. /* parse the header Voyager provides */
  60.  
  61. parse ARG EVENT.TOADDR
  62. if pos('@',EVENT.toaddr) = 0 then exit
  63. call pragma('stack',10000)
  64. file = "t:" || EVENT.TOADDR
  65. address command 'ced -keepio -pubscreen='PubScreen file
  66.  
  67. EVENT.SUBJECT = "mailto: " || EVENT.TOADDR
  68.  
  69. UNIQUEMSGFILE bbsname '"'MailSystem'"' stem UNIQUEFILE
  70. if(rc ~= 0) then
  71. do
  72.     call showerror('UNIQUEMSGFILE BBSRead command failed: ' || BBSREAD.LASTERROR)
  73.     exit 20
  74. end
  75.  
  76. call open(tmp, UNIQUEFILE.NAME, W)
  77.  
  78. if exists(file) then do
  79.  
  80.  call open(temp, file, R)
  81.   do until eof(temp)
  82.    call writeln(tmp,readln(temp))
  83.   end
  84.  call close(temp)
  85.  
  86.  
  87.  /* add signature from the EMail conference/BBS/Global Settings */
  88.  
  89.  if(upper(AddSignature) = 'YES') then
  90.  do
  91.     GETCONFDATA BBSNAME '"'MailSystem'"' CONFNAME '"'MailConfName'"' STEM CONFD
  92.     if(CONFD.SIGNATURE = "") then
  93.     do
  94.         GETBBSDATA BBSNAME '"'MailSystem'"' STEM BBSD
  95.         if(BBSD.SIGNATURE = "") then
  96.         do
  97.             GETGLOBALDATA STEM GLOBD
  98.             if(GLOBD.SIGNATURE = "") then
  99.             do
  100.                 call showerror('No signature configured in either conference, bbs og global settings! Please correct this in THOR or turn off signature adding in SendMail.thor.')
  101.                 exit 20
  102.             end
  103.             else sig = 'thor:' || GLOBD.SIGNATURE
  104.         end
  105.         else sig = 'thor:' || BBSD.SIGNATURE
  106.     end
  107.     else sig = 'thor:' || CONFD.SIGNATURE
  108.  
  109.     drop CONFD.; drop BBSD.; drop GLOBD.
  110.  
  111.     if(sig ~= "") then
  112.     do
  113.         /* signature may be a filename */
  114.  
  115.         if(exists(sig)) then
  116.         do
  117.             call open(sigfh, sig, R)
  118.  
  119.             do until eof(sigfh)
  120.                 call writeln(tmp, readln(sigfh))
  121.             end
  122.  
  123.             call close(sigfh)
  124.         end
  125.         else call writeln(tmp, sig) /* or just a string */
  126.      end
  127.  end
  128.  
  129.  call close(tmp)
  130.  
  131.  /* fill out some more variables that BBSREAD require */
  132.  
  133.  EVENT.CONFERENCE = MailConfName
  134.  EVENT.MSGFILE = UNIQUEFILE.FILEPART
  135.  
  136.  /* write the event */
  137.  
  138.  WRITEBREVENT bbsname '"'MailSystem'"' event 0 stem EVENT
  139.  if(rc ~= 0) then
  140.  do
  141.      call showerror('WRITEBREVENT BBSRead command failed: ' || BBSREAD.LASTERROR)
  142.      exit 20
  143.  end
  144.  
  145.  address command 'c:delete >nil: ' file
  146.  if upper(sendevent) = "Y" then call send
  147. end
  148.  
  149. exit 0
  150.  
  151. /* sophisticated errorhandling :-) */
  152.  
  153. showerror: procedure expose MailSystem MailConfName AddSignature
  154.     parse arg errormsg
  155.  
  156.     p=show('P',,)
  157.     if(pos('MINDWALKER', p) > 0) then vport = word(substr(p, pos('MINDWALKER', p)), 1)
  158.     else return
  159.  
  160.     call open(err, "T:SendMail.thor.error.html", W)
  161.     call writeln(err, "<HTML><HEAD><TITLE>SendMail.thor encountered an error</TITLE></HEAD><BODY><H1>Sending mail aborted</H1>" || errormsg || "<P>Please remember to verify the following settings:<PRE>MailSystem = '" || MailSystem || "'" || '0a'x || "MailConfName = '" || MailConfName || "'" || '0a'x || "AddSignature = '" || AddSignature || "'" || "</PRE>If they are wrong, edit SendMail.thor and correct them. <hr> If this should happen to be an erroneous error, don't hesitate to contact the author, <A HREF=" || '"' || "http://www.cs.uit.no/~troels" || '"' || ">Troels Walsted Hansen</A>, preferably by <A HREF=" || '"' || "mailto:troels@stud.cs.uit.no" || '"' || ">email</A>.")
  162.     call close(err)
  163.  
  164.     address(vport)
  165.     'openURL file://localhost/T:SendMail.thor.error.html'
  166.  
  167.     return
  168.  
  169. SEND:
  170.  
  171. If Show('p', 'AMITCP') = 1 then do
  172.  
  173.    Address BBSREAD
  174.    GETBBSDATA SystemName stem BBSDATA
  175.    If BBSDATA.NUMEVENTS ~= 0 Then do
  176.  
  177.    DO post = 1 TO 10
  178.    address command CmdPath'SendTCP ' MailSystem 'MAILSERVER ' MailServer 'NEWSSERVER ' NewsServer 'pubscreen='PubScreen
  179.    IF RC=0 THEN DO
  180.         LEAVE post
  181.      END
  182.    END
  183.  end
  184. end
  185. RETURN
  186.  
  187. PubScreen:
  188.  
  189.  If show('p', 'MINDWALKER') = 1 then do
  190.   address MINDWALKER
  191.   INFO SCREEN
  192.   PubScreen = result
  193.  end
  194.   else
  195.  PubScreen = 'Workbench'
  196. return
  197.