diff --git a/project/build.scala b/project/build.scala index c5cdd89..856771b 100644 --- a/project/build.scala +++ b/project/build.scala @@ -35,6 +35,7 @@ "commons-io" % "commons-io" % "2.4", "org.pegdown" % "pegdown" % "1.3.0", "org.apache.commons" % "commons-compress" % "1.5", + "org.apache.commons" % "commons-email" % "1.3.1", "com.typesafe.slick" %% "slick" % "1.0.1", "com.novell.ldap" % "jldap" % "2009-10-07", "com.h2database" % "h2" % "1.3.171", diff --git a/src/main/scala/util/Notifier.scala b/src/main/scala/util/Notifier.scala new file mode 100644 index 0000000..dab8eb3 --- /dev/null +++ b/src/main/scala/util/Notifier.scala @@ -0,0 +1,37 @@ +package util + +import org.apache.commons.mail.{DefaultAuthenticator, SimpleEmail} + +import service.SystemSettingsService.{SystemSettings, Smtp} + +trait Notifier { + +} + +object Notifier { + def apply(settings: SystemSettings) = { + new Mailer(settings.smtp.get) + } + +} + +class Mailer(val smtp: Smtp) extends Notifier { + def notifyTo(issue: model.Issue) = { + val email = new SimpleEmail + email.setHostName(smtp.host) + email.setSmtpPort(smtp.port.get) + smtp.user.foreach { user => + email.setAuthenticator(new DefaultAuthenticator(user, smtp.password.getOrElse(""))) + } + smtp.ssl.foreach { ssl => + email.setSSLOnConnect(ssl) + } + email.setFrom("TODO address", "TODO name") + email.addTo("TODO") + email.setSubject(s"[${issue.repositoryName}] ${issue.title} (#${issue.issueId})") + email.setMsg("TODO") + + email.send + } +} +class MockMailer extends Notifier \ No newline at end of file