Reputation: 441
We are using the following snippet of code to send an email from java
javaMailSenderImpl.setHost("somehost");
javaMailSenderImpl.setPort(25);
javaMailSenderImpl.testConnection();
message = new SimpleMailMessage();
message.setFrom("[email protected]");
message.setTo("[email protected]");
message.setText("Hello world!!");
System.out.println("************ before" + LocalTime.now());
javaMailSenderImpl.send(message);
System.out.println("************ after" + LocalTime.now());
JavaMailSenderImpl.send method takes about 6 seconds to execute, is there a way to reduce this time?
Upvotes: 1
Views: 1217
Reputation: 219
Yeah, You are right JavaMailSender
was bit slow. So you can use thread to avoid timing issue. Note- Its not a solution, It's just my suggestion. You can create new thread like this.
new Thread(() -> {
try {
//do your business here
..............
} catch (IOException | MessagingException e) {
e.printStackTrace();
}
}).start();
Upvotes: 1