Search in sources :

Example 6 with SendmailProtocol

use of org.opennms.netmgt.config.javamail.SendmailProtocol 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

SendmailProtocol (org.opennms.netmgt.config.javamail.SendmailProtocol)6 SendmailHost (org.opennms.netmgt.config.javamail.SendmailHost)4 SendmailMessage (org.opennms.netmgt.config.javamail.SendmailMessage)4 UserAuth (org.opennms.netmgt.config.javamail.UserAuth)4 MessagingException (javax.mail.MessagingException)3 SendmailConfig (org.opennms.netmgt.config.javamail.SendmailConfig)3 JavaSendMailer (org.opennms.javamail.JavaSendMailer)2 File (java.io.File)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 NoSuchProviderException (javax.mail.NoSuchProviderException)1 Transport (javax.mail.Transport)1 MimeMessage (javax.mail.internet.MimeMessage)1 JavaMailerException (org.opennms.javamail.JavaMailerException)1 MimeMessageHelper (org.springframework.mail.javamail.MimeMessageHelper)1