java.lang.NoSuchMethodError: com.sun.mail.util.TraceInputStream

By default, Java apps running on latest Heroku stack use OpenJDK 8.

Your problem does not seems related to the actual JVM implementation but rather due to the missing smtp-1.5.1.jar in classpath . To be sure to load correctly TraceInputStream try this :

java.net.URL classUrl = this.getClass().getResource("com.sun.mail.util.TraceInputStream");
out.println(classUrl.getFile());

You've mixed different versions of the API and implementation; don't do that. For that matter, you only need the com.sun.mail:javax.mail dependency. If Heroku isn't providing it in the runtime environment, you'll need to package it in your application. Make sure the JavaMail jar file is ending up in the WEB-INF/lib directory of your application.