Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use play-plugins-mailer with Play 2.3 and Scala 2.11?

I am trying to use the play plugin for sending emails:

https://github.com/playframework/play-mailer

I have followed the instructions as found on github: added the dependency to build.sbt, created play.plugins with the specified content (do I need to register the file somehow)?

but I get a compilation error:

object mailer is not a member of package play.api.libs

when trying to import

import play.api.libs.mailer._

I get another compilation error on

val mail = use[MailerPlugin].email

MailerPlugin and use are not found.

How to get this working?

Note: the plugin is correctly downloaded (I can find it in my .ivy2 directory), but it is not listed as a dependency in my application.

My build.sbt file:

name := ...

version := "1.0-SNAPSHOT"

scalaVersion := "2.11.2"

resolvers += Resolver.typesafeRepo("releases")

//"mysql" % "mysql-connector-java" % "5.1.31"
libraryDependencies ++= Seq(
  "mysql" % "mysql-connector-java" % "5.1.24",
  "org.webjars" %% "webjars-play" % "2.3.0-2",
  "com.typesafe.play" %% "play-slick" % "0.8.0",
  "com.typesafe.play.plugins" %% "play-plugins-mailer" % "2.3.1",
  "org.mindrot" % "jbcrypt" % "0.3m"
)

fork in Test := false

lazy val root = (project in file(".")).enablePlugins(PlayScala)

And my play.plugins contains only:

1500:com.typesafe.plugin.CommonsMailerPlugin

UPDATE: I've downloaded the sample project from https://github.com/playframework/play-mailer and tried to compile using sbt. It failed with exactly the same problem.

like image 382
jfu Avatar asked Nov 25 '14 15:11

jfu


2 Answers

It looks like the problem is somehow with the version of plugin that is available in the typesafe repo:

I've built the plugin from sources, published it to my local repository and then everything compiled fine.

In the build.sbt of the sample app there is:

resolvers += Resolver.file("LocalIvy", file(Path.userHome + File.separator + ".ivy2" + File.separator + "local"))(Resolver.ivyStylePatterns)

So it looks like the authors also had problems in compiling the app using the plugin deployed to the official repository.

UPDATE: Well, it compiled fine, but then failed at runtime with java.lang.ClassNotFoundException: com.typesafe.plugin.CommonsMailerPlugin

UPDATE 2: The sample play.plugins is also wrong, the correct one should be:

1500:play.api.libs.mailer.CommonsMailerPlugin

and then eveyrthing finally works

like image 171
jfu Avatar answered Sep 28 '22 08:09

jfu


The README is up to date with the latest development (upcoming version). As of 19/12/2014, the latest version released and available in the Typesafe repository is 2.3.1. If you want to use this version you need to refer to the README in the v2.3.1 tag: https://github.com/playframework/play-mailer/tree/v2.3.1

For the upcoming version we have decided to break compatibility to move the Play mailer into its own package and provide a better implementation. That's the reason why the documentation in the master branch is not working with version 2.3.1.

like image 23
Mogztter Avatar answered Sep 28 '22 08:09

Mogztter