• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Capture javamail error to file

 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How can i store the javamail error to a file. I m sending mass email and would like to store the error when the email could not be delivered.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just catch the exception thrown and log it into a file.
 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Freddy Wong wrote:Just catch the exception thrown and log it into a file.


Thank you, i did that just now, but the issue now is, suppose i have one email id out of 5 which javamail was not able to deliver to, it does not write to the file which one it is. and also it does not send out mails to any of the other email ids.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need one-by-one error handling you may have to send out the mails individually, instead of all in one go.
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Freddy Wong wrote:Just catch the exception thrown and log it into a file.

A logging framework like Log4J can really help with that. Using a FileAppender (possibly a RollingFileAppender), and using logger.error("message", exception) works like a charm.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic