PrintStream を ByteArrayOutputStream にリンクし、JavaMail に PrintStream を使用するように指示し、JavaMail を実行して、最後に ByteArrayOutputStream の内容をお気に入りのロガーにダンプできます。
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
Session mailSession = Session.getDefaultInstance(props, null);
try {
if (MAIL_DEBUG) {
logger.info("JAVAMAIL debug mode is ON");
mailSession.setDebugOut(ps);
mailSession.setDebug(true);
}
...
transport.close();
if (MAIL_DEBUG) {
logger.info(os);
}
}
finally {
ps.close();
os.close();
}