diff --git a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala index 7841721..bc07e45 100644 --- a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala @@ -174,8 +174,9 @@ post("/admin/system/sendmail", sendMailForm)(adminOnly { form => try { new Mailer(form.smtp).send(form.testAddress, - "Test message from GitBucket", "This is a test message from GitBucket.", - context.loginAccount.get) + "Test message from GitBucket", context.loginAccount.get, + "This is a test message from GitBucket.", None + ) "Test mail has been sent to: " + form.testAddress diff --git a/src/main/scala/gitbucket/core/util/Notifier.scala b/src/main/scala/gitbucket/core/util/Notifier.scala index 4b9a570..61f3c68 100644 --- a/src/main/scala/gitbucket/core/util/Notifier.scala +++ b/src/main/scala/gitbucket/core/util/Notifier.scala @@ -19,12 +19,12 @@ * Please see the plugin for details. */ trait Notifier { - def toNotify(subject: String, htmlMsg: String) + def toNotify(subject: String, textMsg: String) (recipients: Account => Session => Seq[String])(implicit context: Context): Unit = { - toNotify(subject, htmlMsg, None)(recipients) + toNotify(subject, textMsg, None)(recipients) } - def toNotify(subject: String, htmlMsg: String, textMsg: Option[String]) + def toNotify(subject: String, textMsg: String, htmlMsg: Option[String]) (recipients: Account => Session => Seq[String])(implicit context: Context): Unit } @@ -39,7 +39,7 @@ class Mailer(private val smtp: Smtp) extends Notifier { private val logger = LoggerFactory.getLogger(classOf[Mailer]) - def toNotify(subject: String, htmlMsg: String, textMsg: Option[String] = None) + def toNotify(subject: String, textMsg: String, htmlMsg: Option[String] = None) (recipients: Account => Session => Seq[String])(implicit context: Context): Unit = { context.loginAccount.foreach { loginAccount => val database = Database() @@ -47,7 +47,7 @@ val f = Future { database withSession { session => recipients(loginAccount)(session) foreach { to => - send(to, subject, htmlMsg, loginAccount, textMsg) + send(to, subject, loginAccount, textMsg, htmlMsg) } } "Notifications Successful." @@ -59,7 +59,7 @@ } } - def send(to: String, subject: String, htmlMsg: String, loginAccount: Account, textMsg: Option[String] = None): Unit = { + def send(to: String, subject: String, loginAccount: Account, textMsg: String, htmlMsg: Option[String] = None): Unit = { val email = new HtmlEmail email.setHostName(smtp.host) email.setSmtpPort(smtp.port.get) @@ -84,9 +84,9 @@ } email.setCharset("UTF-8") email.setSubject(subject) - email.setHtmlMsg(htmlMsg) - textMsg.foreach{ msg => - email.setTextMsg(msg) + email.setTextMsg(textMsg) + htmlMsg.foreach { msg => + email.setHtmlMsg(msg) } email.addTo(to).send @@ -94,6 +94,6 @@ } class MockMailer extends Notifier { - def toNotify(subject: String, htmlMsg: String, textMsg: Option[String] = None) + def toNotify(subject: String, textMsg: String, htmlMsg: Option[String] = None) (recipients: Account => Session => Seq[String])(implicit context: Context): Unit = () }