Results 1 to 2 of 2
  1. #1
    voipp is offline Member
    Join Date
    Oct 2013
    Rep Power

    Unhappy e-mail messenger can not convert socket to TLS

    i decided to create custom socketFactory so my program is:
    Java Code:
            Properties properties = (Properties)System.getProperties().clone();
            properties.put("mail.transport.protocol", "smtp");
            properties.put("mail.smtp.timeout" , "5000");
            properties.put("", currentSettingsDocument.getSMTPHostServer());
            properties.put("mail.smtp.port", currentSettingsDocument.getSMTPPort());
            properties.put("mail.smtp.auth", "true");
            properties.put("", currentSettingsDocument.getSMTPHostServer());
            //properties.put("mail.debug", "true");
            properties.put("mail.smtp.socketFactory.port", currentSettingsDocument.getSMTPPort());
           properties.put("mail.smtp.socketFactory.class", "DummySSLSocketFactory");
           properties.put("mail.smtp.socketFactory.fallback", "false");
            switch (currentSettingsDocument.getEncryption())
                case TLS:
                    properties.put("mail.smtp.starttls.enable", "true");
                case SSL:
                    properties.put("mail.smtp.socketFactory.port", currentSettingsDocument.getSMTPPort());
                case NONE:
            Authenticator authenticator = new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(currentSettingsDocument.getLogin() , currentSettingsDocument.getPassword());
            properties.put("mail.smtp.starttls.enable", "true");
            Session session = Session.getInstance(properties,authenticator);
            MimeMessage message = new MimeMessage(session);
            message.setFrom(new InternetAddress(currentSettingsDocument.getSenderMail()));
            for(InternetAddress addr: recepients )
            message.addRecipient(Message.RecipientType.TO, addr );
    after compiling i receive :
    Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host:, port: 587;
    nested exception is: Couldn't connect using unknown socket factory to host, port:, -1; Exception: java.lang.ClassNotFoundException: DummySSLSocketFactory
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTra
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SM
    at javax.mail.Service.connect(
    at XMailMessenger.MailMessenger.sendMail(MailMessenge
    at alfa.runner.main(
    I brought DummySSLSocketFactory class from Oracle FAQ site and put it in my folder, where java code above is situated.
    And i dont understand, why it is necessary to include SSSLSocketFactory in my TLS connection to Google SMTP-server.
    Please, help me to solve ClassNotFound exception!

    PS dont ask me why i am using Dummy classes, it because of the other exception

  2. #2
    voipp is offline Member
    Join Date
    Oct 2013
    Rep Power

    Default Re: e-mail messenger can not convert socket to TLS

    Everything ok if this function not static!

Similar Threads

  1. Replies: 0
    Last Post: 11-06-2012, 08:27 AM
  2. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 05:37 AM
  3. Replies: 2
    Last Post: 07-25-2009, 09:36 AM
  4. Replies: 2
    Last Post: 05-05-2008, 06:01 AM
  5. Sending a mail with the local mail program
    By thedude in forum Advanced Java
    Replies: 2
    Last Post: 07-23-2007, 12:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts