home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / uqwk18.zip / Mail.cmd < prev    next >
OS/2 REXX Batch file  |  1994-09-11  |  1KB  |  53 lines

  1. /* !CRF! - Mail.cmd */
  2. /*
  3.    This is a simple mail program for use with UQWK with parameters that
  4.    are compatible with Unix's Mail.
  5.  
  6.    Only supports the following two command line forms:
  7.         mail -s 'The Subject' joe@host.domain
  8.         mail -s 'The Subject' 'joe@host.domain (Joe Smith)'
  9.  
  10.    The MAILER environment variable must be set.
  11.  
  12.    Written by Claudio Fahey (claudio@uclink.berkeley.edu)
  13. */
  14.  
  15. /* Load rexxutil SysTempFileName and SysFileDelete */
  16. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  17. call SysLoadFuncs
  18.  
  19. parse arg "-s '" subject "' " to
  20.  
  21. if subject = '' | to = '' then do
  22.     call lineout 'stderr:', 'MAIL.CMD: ERROR: Required subject or to-address not specified'
  23.     exit 1
  24.     end
  25.  
  26. /* See if to-address is enclosed in single quotes */
  27. parse var to "'"temp"'"
  28. if temp \= '' then
  29.     to = temp
  30.  
  31. tempfile = systempfilename(value('TEMP',,'OS2ENVIRONMENT') || '\MailCmd.???')
  32.  
  33. call lineout tempfile, 'To:' to
  34. call lineout tempfile, 'Subject:' subject
  35.  
  36. /* If any other headers need to be sent with the message, place them here */
  37.  
  38. call lineout tempfile, ''
  39.  
  40. /* copy message from stdin to temp file */
  41. do while lines()
  42.     call lineout tempfile, linein()
  43.     end
  44.  
  45. /* Close temp file */
  46. call lineout tempfile
  47.  
  48. /* Run MAILER (usually sendmail) */
  49. '@'getenv('MAILER',,'OS2ENVIRONMENT') '-t <' tempfile
  50.  
  51. call sysfiledelete(tempfile)
  52.  
  53.