I'm confused by the Swing program. I add a button event to send mail, the code is below, in which use SpringMail API to send the mail.
but it doesn't work when I click the button and also the program seem to be dead. When I debug it, it stop at the line 'mailSender.send(msg);' and can not finish. The code is no problem if I put them in main() function and test it.
I Know the Swing has the eveet dispatch thread, is there any problem with threads? To be honest, I'm not familiar with Java Concurrency.
How can solve this problem?
pls help!
private void sendMailButtonActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println("Sending Mail Start");
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(server.getHost());
mailSender.setUsername(server.getUsername());
mailSender.setPassword(server.getPassword());
SimpleMailMessage msg = new SimpleMailMessage();
msg.setFrom(mail.getFrom());
msg.setTo(mail.getTo());
msg.setSubject(mail.getSubject());
msg.setText(mail.getContent());
mailSender.send(msg);
System.out.println("Sending Mail End");
}