use of org.opennms.netmgt.config.javamail.SendmailConfig in project opennms by OpenNMS.
the class DefaultJavamailConfigurationDao method removeSendMailConfig.
/* (non-Javadoc)
* @see org.opennms.netmgt.dao.api.JavaMailConfigurationDao#removeSendMailConfig(java.lang.String)
*/
@Override
public boolean removeSendMailConfig(String sendmailConfig) {
int index = -1;
List<SendmailConfig> configs = getSendmailConfigs();
for (int i = 0; i < configs.size(); i++) {
final SendmailConfig c = configs.get(i);
if (c.getName() != null && c.getName().equals(sendmailConfig)) {
index = i;
break;
}
}
if (index > -1) {
configs.remove(index);
return true;
}
return false;
}
use of org.opennms.netmgt.config.javamail.SendmailConfig in project opennms by OpenNMS.
the class DefaultJavamailConfigurationDao method getSendMailConfig.
/* (non-Javadoc)
* @see org.opennms.netmgt.dao.api.JavaMailConfigurationDao#getSendMailConfig(java.lang.String)
*/
@Override
public SendmailConfig getSendMailConfig(String name) {
SendmailConfig config = null;
List<SendmailConfig> configs = getSendmailConfigs();
for (SendmailConfig sendmailConfig : configs) {
if (sendmailConfig.getName() != null && sendmailConfig.getName().equals(name)) {
config = sendmailConfig;
}
}
return config;
}
use of org.opennms.netmgt.config.javamail.SendmailConfig in project opennms by OpenNMS.
the class JavaReadMailerTest method createSendMailer.
private JavaSendMailer createSendMailer(String gmailAccount, String gmailPassword) throws JavaMailerException {
SendmailConfig config = new SendmailConfig();
config.setAttemptInterval(1000l);
config.setDebug(true);
config.setName("test");
SendmailMessage sendmailMessage = new SendmailMessage();
sendmailMessage.setBody("service is down");
sendmailMessage.setFrom("bamboo.opennms@gmail.com");
sendmailMessage.setSubject("Notice #1234: service down");
sendmailMessage.setTo("bamboo.opennms@gmail.com");
config.setSendmailMessage(sendmailMessage);
SendmailHost host = new SendmailHost();
host.setHost("smtp.gmail.com");
host.setPort(465);
config.setSendmailHost(host);
SendmailProtocol protocol = new SendmailProtocol();
protocol.setSslEnable(true);
protocol.setTransport("smtps");
config.setSendmailProtocol(protocol);
config.setUseAuthentication(true);
config.setUseJmta(false);
UserAuth auth = new UserAuth();
auth.setUserName(gmailAccount);
auth.setPassword(gmailPassword);
config.setUserAuth(auth);
return new JavaSendMailer(config);
}
Aggregations