0

Using JavaMail, I am creating a program that can handle bounced email. I referring to this tutorial http://www.tutorialspoint.com/javamail_api/javamail_api_bounced_messages.htm.

Is there a way to catch if the email is bounced?

boolean bounce = false; //how can i make this TRUE if the email is bounced?
try {
   System.out.println("Sending ....");
   transport.connect(smtpServer, port, userid, password);
   transport.sendMessage(message,
   message.getRecipients(Message.RecipientType.TO));
   System.out.println("Sending done ...");
} catch (Exception e) {
   System.err.println("Error Sending: ");
   e.printStackTrace();
}

Thanks in advance!

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
jitd
  • 45
  • 1
  • 10
  • Since that's more or less an asynchronous event you probably can't set `bounce` to true in that call. You'd have to react on the bounce messages (emails) you get eventually (if you even do get them due to security settings on the receiving server etc.). – Thomas Jul 22 '16 at 08:41
  • 1
    See [this answer](http://stackoverflow.com/questions/38377409/parsing-bounced-emails-using-javamail-and-dsn-jar/38381045#38381045) for more detail about handling bounced messages. – Bill Shannon Jul 22 '16 at 17:53
  • @BillShannon Thanks! I can now get bounced messages by accessing mail folder. – jitd Aug 01 '16 at 06:20

0 Answers0