MailConfiguration config = (MailConfiguration) ref.get(0).getContent();
// Note: javax.mail.Session is not serializable,
// but we need to get a new instance on every lookup.
Properties props = config.getMailProperties();
javax.mail.Session s = javax.mail.Session.getInstance(props, new MailSessionAuthenticator(props));
if("smtps".equals(props.getProperty("mail.transport.protocol"))) {
s.setProtocolForAddress("rfc822", "smtps");
}
s.setDebugOut(new PrintStream(new MailLogOutputStream()));
s.setDebug(true);