我是Scala的新手,我被困在发送电子邮件......
我正在玩Play! 2.4并且必须遵循 build.scala
"com.typesafe.play" %% "play-mailer" % "3.0.1"
在application.conf中有以下内容:
play.mailer {
host=smtp.gmail.com
port=587
ssl=true
tls=true
user="testme@gmail.com"
password=abracadabra
debug=true
}
我要做的是向用户发送电子邮件,例如user_1,当其他用户user_2从user_1借阅图书时。
在我的书籍控制器中,我有这样的方法:
def sendEmail(email_user: String, subject: String, msg: String): Unit = {
val email = Email(
subject,
"FROM <testme@gmail.com>",
Seq("TO <"+email_user+">"),
bodyText = Some(msg)
)
}
在下一个方法中,如果user_2从user_1借阅了一本书,我会调用 sendEmail 方法
def borrowBook(id_book: Long) = Action { implicit request =>
val nr = Book.checkBook(id_book)
val date = new Date()
if(nr > 0)
{
val list = Book.getCarte(id_book)
val no = Friend.isFriend(list.id_user, userInfo.id.get)
if(no == 1){
Borrow.insert(Borrow(id_book, userInfo.id.get, date))
sendEmail(userInfo.email, "Borrow book", "Your book has been borrowed")
Ok(views.html.borrowBook())
}else Ok(views.html.warningBorrow())
}
else Ok(views.html.failBorrow())
}
问题是我没有收到任何错误或类似的东西,我不知道我做错了什么。
有人可以帮助我吗?
非常感谢!