Make sure all the JARs that you need (as third-party libraries) are on your classpath (when you run the program). Look at the -cp option when calling the JVM. Something like: java -cp ... should solve your problem.
Set the mail.smtp.reportsuccess session property to true. This will cause Transport.send to always throw SendFailedException. You should also change the code to use Session.getInstance.