(refs #10) Creates a E-mail sending. still working on...

This commit is contained in:
shimamoto
2013-08-23 22:30:40 +09:00
parent 6b57cca64d
commit 6d76e93ede
2 changed files with 38 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ object MyBuild extends Build {
"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",

View File

@@ -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