Thankyou John Meyers, I have looked into the JavaMail tutorial and I am not convinced with the output. I'm still getting errors while sending. I want the code for sending the mail. For that i've used this code and it is working in my localhost system, but when i uploaded to the remote server, it is not working. Can you please tell me the reason?
If it is working when run on your local system but not on a server, the problem could be security at the mail server. Typically mail servers only accept outgoing mail from certain senders and your JSP server is not cleared to send mail through the system you are trying to use.
When sending an message with html use the set content method of the MimeMessage class. i.e mimeMessage.setContent(htmlString,"text/html");
You may want to check the implementation of transport.send and smtptransport. I think it blocks until the first server in the delivery chain accepts the message for each recipient (cant remember exactly). If this is the case, sending the mail asynchronously will provide a better user experience especially in cases where a MX record points to a dead or slow server.