I was code a java email sending program. But when i click the send button the button appear hanging mode & program still running, but mail did not send.
I can't detect the problem. can anybody help me... 
The code is below.

```
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    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.starttls.enable", "false");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.port", "465");

    Session session = Session.getDefaultInstance(props,
            new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication("myid@gmail.com", "password");
                }
            }
    );

    try {
        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress("myid@gmail.com"));
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("senderid@gmail.com"));
        message.setSubject("Demo mail");
        message.setText("Hello, world!");
        Transport.send(message);

        JOptionPane.showMessageDialog(this, "Message sent!");
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e);
    }

```

My email account have not activate 2-step verification service.
And it also work in outlook email sending software.. I tested.

But not work on my java program.