(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

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