use of org.opennms.netmgt.config.javamail.JavamailProperty in project opennms by OpenNMS.
the class JavaReadMailer method configureProperties.
/**
* Configures the java mail api properties based on the settings ReadMailConfig
* @return A set of javamail properties based on the mail configuration
* @throws JavaMailerException
*/
private Properties configureProperties() throws JavaMailerException {
Properties props = new Properties();
props.setProperty("mail.debug", String.valueOf(m_config.isDebug()));
//first set the actual properties defined in the sendmail configuration
List<JavamailProperty> jmps = m_config.getJavamailProperties();
for (JavamailProperty jmp : jmps) {
props.setProperty(jmp.getName(), jmp.getValue());
}
final ReadmailHost readmailHost = getReadmailHost(m_config);
final UserAuth userAuth = getUserAuth(m_config);
String protocol = readmailHost.getReadmailProtocol().getTransport();
props.put("mail." + protocol + ".host", readmailHost.getHost());
props.put("mail." + protocol + ".user", userAuth.getUserName());
props.put("mail." + protocol + ".port", readmailHost.getPort());
props.put("mail." + protocol + ".starttls.enable", readmailHost.getReadmailProtocol().isStartTls());
props.put("mail.smtp.auth", "true");
if (readmailHost.getReadmailProtocol().isSslEnable()) {
props.put("mail." + protocol + ".socketFactory.port", readmailHost.getPort());
props.put("mail." + protocol + ".socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail." + protocol + ".socketFactory.fallback", "false");
}
//FIXME: need config for these
props.put("mail." + protocol + ".connectiontimeout", 3000);
props.put("mail." + protocol + ".timeout", 3000);
props.put("mail.store.protocol", protocol);
return props;
}
Aggregations