p.put("mail.smtp.host", mailhost);
p.put("mail.smtp.timeout", mailhostTimeout);
p.put("mail.smtp.connectiontimeout", mailhostTimeout);
p.put("mail.smtp.ssl.enable", sslEnabled);
p.put("mail.smtp.ssl.checkserveridentity", sslCheckCertificate);
Session mailSession;
if (smtpAuth == null) {
mailSession = javax.mail.Session.getInstance(p);
} else {
// use smtp authentication from configuration
p.put("mail.smtp.auth", "true");
mailSession = Session.getDefaultInstance(p, smtpAuth);
}
if (Tracing.isDebugEnabled(MailHelper.class)) {
// enable mail session debugging on console
mailSession.setDebug(true);
}
return new MimeMessage(mailSession);
}