Mail API & Retrying Host
Posted on 2002-06-18
I have a working app that send mail successfully when the mail server is ok (obvious so far!).
What I want to be able to do is detect that the host is not available and retry with a second host.
I'd like to be able to detect this before sending a message, such as in the code:
Session session = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(session);
Where props contains the host name.
I know that the host could fail at any point after this, and during the sending of a particular message.
It would be good to be able to catch an exception (MessagingException?) at the point of making the host connection, and if it fails, try another host. It would be even better to be able to detect the failed host connection during sending each message and retry with another host, but I think that is more difficult, given the connection has already been made.