Today I dug into someone else's project to help fix it, and when I got to the part about sending email messages from within the program, I kept getting this JavaMail API exception:
JavaMail is usually pretty easy to setup and get running (assuming you have an SMTP server you can use), so it was a surprise to see this problem. To make a long story short, I found that the person who created this project had the wrong jar files in his project to handle the process of sending mail from a Java program. He had these two files:
The name of the
activation.jar file looked right, but I didn't know what the other one was. I've always seen it named
mail.jar, so again, keeping this short, I deleted his jar files and replaced them with jar files from these two URLs, and then everything magically started working:
Once those two JavaMail API jar files were replaced, the email code worked just fine.
Jar file-naming best practice
As a quick side note, I like the Apache method for naming jar files with version information, so I named these two jar files
mail-1.4.1.jar. When you're in a situation like this, in a crunch and trying to figure out what someone else has done, I think this information is very helpful.