MetroidFan2002
MetroidFan2002

Reputation: 29878

Is Javamail asynchronous or synchronous?

Is Javamail asynchronous or synchronous? That is, if I send off an email, do I continue processing immediately afterwards, or do I wait until it's complete?

Furthermore, are there any ways that I could catch that an email failed to be delivered for any reason?

I'd also like to know these answers for Spring's MailSender abstraction.

Thanks.

Upvotes: 6

Views: 3084

Answers (1)

Matthew Flaschen
Matthew Flaschen

Reputation: 284796

It is synchronous, since it transfers the message to the server and processes the server's response before returning. The send docs explain in further detail. The message will throw a SendFailedException, or another MessagingException, if the send fails immediately. But "success does not imply that the message was delivered to the ultimate recipient, as failures may occur in later stages of delivery."

Upvotes: 6

Related Questions