I was trying to send email using simple method and it was very slower. and some told me to send email via Asynchronous API.
This was my old question Email code makes the code slower in java spring MVC
can anyone guide on this what is that and how will it make sending email faster
The Google App Engine implementation of Javamail API allows you to send mail asynchronously, but I don't know if it is feasible to embed it in a servlet. Even if it is not feasible to use GAE like this, it proves that it is possible to implement a javamail provider that does asynchronous mail sending.
Another alternative is to set up local mail service to act as a relay for your Java application. If configured correctly, this should allow you to get messages off your hands in milliseconds. It can also take care of issues such as remote mail servers being temporarily down. The downside is that you have another service to maintain, and your Java application don't get any notification of failure to deliver mail to the ultimate recipients.
Setup an Executor bean that uses a thread pool executor in your spring context and use it to enqueue a work item that will send the email. It will then be dispatched on a thread pool thread asynchronously and therefore your request thread will not block.
If you happen to run on a Java EE 6 server (JBoss AS 6, Glassfish v3, Resin 4), you can add a simple EJB bean, mark a method with @Asynchronous and send the email from there.
E.g.
I think you can use Google App Engine using Java. It is asynchronous too.
In Spring MVC we have TaskExecutor which makes sending asynchronous mails easy.
Your java class should look like this: