Always jumps "send hello first" error
props.put("mail.smtp.transport.protocol", "smtp");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtpserver.domain.com");
props.put("mail.smtp.localhost", "mypc.mydomain.com);
props.put("mail.smtp.auth", "true");
Session sesion = Session.getDefaultInstance(props);
try {
Transport transport = sesion.getTransport("smtp");
MimeMessage msg = new MimeMessage(sesion);
sesion.setDebug(true);
msg.setFrom(new InternetAddress("from@domain.com"));
InternetAddress[] address = { new InternetAddress("to@domain.com") };
msg.addRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test");
msg.setText("This is a test", "text/plain");
transport.connect(host, port, username, password);
transport.sendMessage(msg, msg.getRecipients(Message.RecipientType.TO));
transport.close();
} catch (MessagingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}