import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; class SendMailSSL{ public static void send(String from,String password,String to,String sub,String msg){ //Get properties object Properties props = new 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"); //get Session Session session = Session.getDefaultInstance(props, //Als zweites argument den Rexxproxy verwenden new javax.mail.Authenticator() { //Wie ist die Klase definiert. Eigene Klasse in Rexx schreiben + Methode protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(from,password); //Als Attribute speichern / expose } }); //compose message try { MimeMessage message = new MimeMessage(session); message.addRecipient(Message.RecipientType.TO,new InternetAddress(to)); message.setSubject(sub); message.setText(msg); //send message Transport.send(message); System.out.println("message sent successfully"); } catch (MessagingException e) {throw new RuntimeException(e);} } public static void main(String[] args) { String fromAddress, password, toAddress, subject, text; if (args.length>0) fromAddress=args[0]; else fromAddress="nixi-oorexx1@gmail.com"; if (args.length>1) password =args[1]; else password ="fabianfuchs"; if (args.length>2) toAddress =args[2]; else toAddress ="noxi-fabian-fuchs@a1.net"; if (args.length>3) subject =args[3]; else subject ="Hallo von Gruppe 2"; if (args.length>4) text =args[4]; else text ="Leider hat es in Rexx nicht funktioniert"; //from,password,to,subject,message // Mailer.send("oorexx1@gmail.com","fabianfuchs","fabian-fuchs@a1.net","Hallo von Gruppe 2","Leider hat es in Rexx nicht funktioniert"); System.out.println("about to invoke send("+fromAddress+","+password+","+toAddress+","+subject+","+text); send(fromAddress, password, toAddress, subject, text); //change from, password and to } }