home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / slip-cm.zip / sendmail.cmd < prev    next >
OS/2 REXX Batch file  |  1994-04-07  |  3KB  |  81 lines

  1. /******************************************************************/
  2. /* SENDMAIL.CMD                                                   */
  3. /*                                                                */
  4. /*     This program acts as a front end for IBM TCP/IP SENDMAIL   */
  5. /*     in a SLIP-only environment.  The program acts as follows:  */
  6. /*                                                                */
  7. /*     * If this is a server invokation (-bd), execute the "real" */
  8. /*       SENDMAIL.EXE, which has been stored in the \MODIFIED     */
  9. /*       subdirectory of the TCP/IP \BIN directory.               */
  10. /*                                                                */
  11. /*     * If the SLIP driver is active (determining this requires  */
  12. /*       TASKS.CMD and TASK_ACTIVE.CMD), any parameters are       */
  13. /*       passed to LAMPOP.EXE.                                    */
  14. /*                                                                */
  15. /*     * Otherwise, the SENDMAIL command is written to the        */
  16. /*       pending mail queue, called PENDING_MAIL, in the          */
  17. /*       \TMP directory.  If there is a file in the pipe, write   */
  18. /*       that to a unique fileid in the \TMP directory and modify */
  19. /*       the SENDMAIL command accordingly.                        */
  20. /*                                                                */
  21. /* Assumptions:                                                   */
  22. /*                                                                */
  23. /*     * LAMAIL will be used for sending mail                     */
  24. /*     * TCPBIN variable has been set in CONFIG.SYS               */
  25. /*     * "Real" SENDMAIL.EXE has been moved to \BIN\MODIFIED      */
  26. /*     * Only the following two forms of SENDMAIL calls are used: */
  27. /*                                                                */
  28. /*       sendmail -bd -q[n]m                                      */
  29. /*       sendmail -f [sender] [recipient] < [mail_file]           */
  30. /*                                                                */
  31. /******************************************************************/
  32.  
  33. trace OFF
  34.  
  35.    address CMD
  36.  
  37.    parse arg parameters
  38.    parse upper arg _PARAMETERS
  39.  
  40.    error = 0
  41.  
  42.    run = Value('TCPBIN',, 'OS2ENVIRONMENT')
  43.    server = Value('SLIP.POP_SERVER',, 'OS2ENVIRONMENT')
  44.    user = Value('SLIP.USERNAME',, 'OS2ENVIRONMENT')
  45.    password = Value('SLIP.PASSWORD',, 'OS2ENVIRONMENT')
  46.  
  47.    send_mail = ('@' || run || '\modified\sendmail.exe')
  48.    send_pop = ('@' || 'lampop -s' server user password)
  49.  
  50.    select
  51.      when (pos("-BD", _PARAMETERS) <> 0) then do
  52.        address CMD send_mail parameters
  53.        error = RC
  54.      end /* when */
  55.  
  56.      when task_active(SLIP, tasks()) then do
  57.        address CMD send_pop parameters
  58.        error = RC
  59.      end /* when */
  60.  
  61.      otherwise do
  62.        work = Value('TMP',, 'OS2ENVIRONMENT')
  63.        list = (work || '\' || 'pending_mail')
  64.        file = (work || '\' || sdate())
  65.  
  66.        do write = 1 by 1 while lines() & (error == 0)
  67.          error = lineout(file, linein())
  68.        end write
  69.  
  70.        if (error == 0) then do
  71.          command = (send_mail "-af" file parameters)
  72.          error = lineout(list, command) 
  73.        end /* if */
  74.  
  75.        call stream file, 'COMMAND', 'CLOSE'
  76.        call stream list, 'COMMAND', 'CLOSE'
  77.      end /* otherwise */
  78.    end /* select */
  79.  
  80. exit (error)
  81.