The JavaMail API is a nice, simple, and effective API. But it’s got one problem: it’s a bugger to unit test. This is mostly because (unlike most other Sun Java APIs) there are no real interfaces in place, which makes it hard to mock pieces out. An excellent solution to this problem is Dumbster
Rather than ramble on to much about it, I’ll just refer to the excellent Dumbster documentation and to a good post by Mike Clark Between these, there is little need for me to add my own 2.2 cents.
What I would say, however, is that it is dead easy to use. A few minutes had it dropped into an existing unit test, and validating all the details I cared about. About the only quirk it has is that it is distributed just as source, so you have to run the build script first; not that big a deal really.