1 Reply Latest reply on Jan 13, 2007 5:56 PM by Radouane El Marjani

    JBOSS SMTP+TLS

    Michal Kalanski Newbie

      PLEASE HELP ME
      I try to to connect to smtp mail server with TLS. I have JBOSS 4.0.1Sp1. I repleced mail.jar from server/default/lib with the latest version 1.4.(this version support SMTP+TLS)
      I have the sample code which is working outside the JBOSS but not in JBOSS:
      String port = "25";
      java.util.Properties props = new java.util.Properties();
      props.setProperty("mail.debug", "true");
      props.setProperty("mail.smtps.socketFactory.port", port);
      props.setProperty("mail.smtps.socketFactory.fallback", "false");
      props.setProperty("mail.smtps.auth", "true");
      props.put("mail.smtps.host", "hermenegilda.intranet");
      props.put("mail.smtp.host", "hermenegilda.intranet");
      props.put("mail.smtp.port", 25);
      props.put("mail.smtp.auth", "true");
      props.setProperty("mail.smtp.starttls.enable", "true");
      java.security.Security.setProperty("ssl.SocketFactory.provider","com.zetokatowice.talgos.common.util.mail.DummySSLSocketFactory");
      try {
      Session session = Session.getInstance(props, new Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication("ts", "ts");
      }
      });
      MimeMessage msg = new MimeMessage(session);
      msg.setText("test");
      msg.setSubject("test");
      msg.setFrom(new InternetAddress("ts@hermenegilda.intranet"));
      msg.setRecipient(Message.RecipientType.TO, new InternetAddress("kalanskim@zeto.intranet"));
      Transport tr = session.getTransport("smtp");
      tr.connect();
      tr.sendMessage(msg, msg.getAllRecipients());
      tr.close();
      } catch (Exception e) {
      e.printStackTrace();
      }


      When I run this code outside the JBOSS, TLS connection is open using my DummySSLSocketFactory but when i try to run it on JBOSS connection is opend using default factory.

      How to tell JBOSS to use my DummySSLSocketFactory ?