Search in sources :

Example 6 with SendmailConfig

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;
}
Also used : SendmailConfig(org.opennms.netmgt.config.javamail.SendmailConfig)

Example 7 with SendmailConfig

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;
}
Also used : SendmailConfig(org.opennms.netmgt.config.javamail.SendmailConfig)

Example 8 with SendmailConfig

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);
}
Also used : SendmailProtocol(org.opennms.netmgt.config.javamail.SendmailProtocol) SendmailMessage(org.opennms.netmgt.config.javamail.SendmailMessage) SendmailConfig(org.opennms.netmgt.config.javamail.SendmailConfig) UserAuth(org.opennms.netmgt.config.javamail.UserAuth) SendmailHost(org.opennms.netmgt.config.javamail.SendmailHost)

Aggregations

SendmailConfig (org.opennms.netmgt.config.javamail.SendmailConfig)8 SendmailMessage (org.opennms.netmgt.config.javamail.SendmailMessage)3 SendmailProtocol (org.opennms.netmgt.config.javamail.SendmailProtocol)3 InetAddress (java.net.InetAddress)2 Test (org.junit.Test)2 JavaSendMailer (org.opennms.javamail.JavaSendMailer)2 NorthboundAlarm (org.opennms.netmgt.alarmd.api.NorthboundAlarm)2 SendmailHost (org.opennms.netmgt.config.javamail.SendmailHost)2 UserAuth (org.opennms.netmgt.config.javamail.UserAuth)2 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)2 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)2 File (java.io.File)1 MessagingException (javax.mail.MessagingException)1 MimeMessage (javax.mail.internet.MimeMessage)1 JavaMailerException (org.opennms.javamail.JavaMailerException)1 MimeMessageHelper (org.springframework.mail.javamail.MimeMessageHelper)1