Hi All,
I have written a code to send an email through SMTP server.
i make use of javax.mail APIs to achieve the same.
My code looks like the below example code:
Sending mail through java
Sometimes when the server is busy i get exception like the following:
1. java.net.SocketTimeoutException : 421 Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Service not available, closing transmission channel
2. javax.mail.MessagingException : Could not connect to SMTP host: hostName , port: 25, response: 421
Now i need to handle these exception with a retrying option.
Kindly suggest me whats the best option to retry sending the mail.
While retrying too, there might be exception again. Can we handle the same?
Thanks in Advance.