Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javamail is evil![rant]

Geoffrey Falk
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys,
I have been wanting to write a mailing list application in Java, and also some kind of application to split and index my old inboxes. Naturally a large part of the problem domain is the concept of messages and message handling.
I have been playing around with JavaMail and I have concluded that it has a poor design, that is not very flexible.
The main problem with the design of JavaMail is that it closely couples the concept of a "Message" with other concepts such as "Session" and "Folder", which actually have nothing to do with the kind of data that are meaningful in an Internet e-mail message.
In fact you cannot create a MimeMessage without reference to these transient entities. But "Session" is only meaningful when you have a connection to a mail server. And "Folder" is only meaningful when the message has actually been filed in (one) folder.
What's more, logically a "Message" object should also be serializable, since it is just a bunch of data. Whereas in JavaMail it can't be, because it needs a reference to the transient objects I referred to earlier (either a Session or a Folder). This is causing a problem, because I also want to use JMS to shuffle the messages around.
I think that an object representation of an e-mail message should be a pure data object. It should store the header information and the data in the message body. It needs methods to get the data from those fields in a meaningful way. There must also be a way to parse an input stream containing an e-mail message and return a representation of a Message object (for example, when processing an incoming SMTP request, or splitting/filing messages from old Unix-style inboxes).
On the other hand, I would like to take advantage of the JavaMail functionality to parse RFC822 headers, and to handle MIME parts. But so far I have not found a very elegant way to do it.
Any comments from people who have used JavaMail, or better, from the folks who actually developed it, would be most welcome.
[ February 20, 2003: Message edited by: Geoffrey Falk ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic