-- get and parse command line arguments, if any parse arg fromAddress password toAddress subject text if fromAddress="" then fromAddress="nixi-oorexx1@gmail.com" if password ="" then password ="fabianfuchs" if toAddress ="" then toAddress ="noxi-fabian-fuchs@a1.net" if subject ="" then subject ="Hallo von Gruppe 2" if text ="" then text ="Leider hat es in Rexx nicht funktioniert" say "about to invoke send("||fromAddress","password","toAddress","subject","text")" signal on syntax -- if something goes wrong, show what call send fromAddress, password, toAddress, subject, text return syntax: -- show entire Java exception chain co=condition("obj") say ppJavaExceptionChain(co) raise propagate -- let ooRexx handle exception, creates Rexx error message ::requires "BSF.CLS" -- get Java bridge ::routine send use strict arg fromAddress, password, toAddress, subject, text props=.bsf~new("java.util.Properties") props~put("mail.smtp.host", "smtp.gmail.com") props~put("mail.smtp.socketFactory.port", "465") props~put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory") props~put("mail.smtp.auth", "true") props~put("mail.smtp.port", "465") -- create a proxy Java class that relays "getPasswordAuthentication" method invocations to the RexxProxy handler jclzAuthenticator=bsf.createProxyClass("javax.mail.Authenticator", , "getPasswordAuthentication") -- create the RexxProxy handler object jRxAuth=BsfCreateRexxProxy(.RexxAuthenticator~new(fromAddress, password)) -- create an instance of the proxy Java class supply the RexxProxy handler jAuth=jclzAuthenticator~new(jRxAuth) -- create Java object and supply RexxProxy -- session=bsf.loadClass("javax.mail.Session")~getDefaultInstance(props, jRxAuth) session=bsf.loadClass("javax.mail.Session")~getDefaultInstance(props, jAuth) msg=.bsf~new("javax.mail.internet.MimeMessage", session) msg~addRecipient(bsf.loadClass("javax.mail.Message$RecipientType")~to, - .bsf~new("javax.mail.internet.InternetAddress",toAddress)) msg~setSubject(subject) -- alternative: msg~subject=subject msg~setText(text) -- alternative: msg~text =text bsf.loadClass("javax.mail.Transport")~bsf.invoke("send",msg) /* ======================================================================== */ -- the RexxProxy handler ::class RexxAuthenticator -- implements "getPasswordAuthentication" from abstract "javax.mail.Authenticator" class ::method init -- ooRexx constructor expose passwordAuthentication use strict arg from, password -- create the password authentication object passwordAuthentication=.bsf~new("javax.mail.PasswordAuthentication", from, password) ::method getPasswordAuthentication -- returns the password authentication object expose passwordAuthentication return passwordAuthentication