Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 830
MetroidFan2002 Avatar asked Nov 30 '10 14:11

MetroidFan2002


People also ask

What is JavaMail used for?

The JavaMail is an API that is used to compose, write and read electronic messages (emails). The JavaMail API provides protocol-independent and plateform-independent framework for sending and receiving mails.

Which protocol is used to receive the messages in JavaMail?

SMTP– Simple Mail Transfer Protocol is used for sending e-mails. POP3– Post Office Protocol is used to receive e-mails. It provides one to one mapping for users and mail boxes, which is one mail box for one user. IMAP– Internet Message Access Protocol is also used to receive e-mails.

What is SMTP Java?

SMTP is an acronym for Simple Mail Transfer Protocol. It is an Internet standard for electronic mail (e-mail) transmission across Internet Protocol (IP) networks.


1 Answers

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."

like image 77
Matthew Flaschen Avatar answered Sep 24 '22 20:09

Matthew Flaschen