Some classes of JavaMail are included in appengine-api-1.0-sdk jar (javax.mail), but not all. I need to add some more classes from JavaMail (e.g. com.sun.mail.imap). When adding JavaMail version 1.5.6 I get compatibility issues. When adding JavaMail version 1.4.7 things seem to work fine so far.
What exact version of JavaMail is included in Google App Engine version 1.9.38 (or newer)? How can I find out on my own?
When prioritizing JavaMail jar over the Google App Engine jars, I get security exceptions. Is there any trick to use a newer JavaMail than included in Google App Engine? Does JavaMail in Google App Engine ever gets updated? It's sad to miss features and bugfixes of newer versions.
The most common ways are to enable debugging or read from the package.
Session s = Session.getInstance(new Properties());
s.setDebug(true); //Prints the version to System.out
System.out.println(Session.class.getPackage());
You can reference the JavaMail CHANGES.txt, Issue Tracker and the repository then look for bugs that have been fixed in each version.
For instance you can tell if it is JavaMail 1.4.4 MimeMessage.setFrom has a chained cause:
try {
Properties props = new Properties();
props.put("mail.from", "one four four@@or.newer");
Session s = Session.getInstance(props);
new MimeMessage(s).setFrom();
} catch (MessagingException me) {
Throwable cause = me.getNextException();
if (cause == null) {
System.err.println("JavaMail 1.4.3 or older.");
} else if (cause instanceof AddressException) {
System.err.println("JavaMail 1.4.4 or newer.");
} else {
me.printStackTrace();
}
}
JavaMail 1.4.5 if MimeMessage.setRecipients(type, String) does accept null address:
try {
Properties props = new Properties();
Session s = Session.getInstance(props);
new MimeMessage(s).setRecipients(Message.RecipientType.TO, (String) null);
System.err.println("JavaMail 1.4.5 or newer.");
} catch (NullPointerException me) {
System.err.println("JavaMail 1.4.4 or older.");
}
JavaMail 1.4.6 if it supports java.util.logging
:
Session s = Session.getInstance(props);
Logger.getLogger("javax.mail").addHandler(new Handler() {
@Override
public void publish(LogRecord record) {
System.out.println(new SimpleFormatter().format(record));
}
@Override
public void flush() {
}
@Override
public void close() {
}
});
s.setDebug(true);