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

I am trying to use the plugin to send emails:

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

I followed the instructions found on github: added a dependency for 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 its use were not found.

How to do it?

Note: the plugin is loaded correctly (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 only contain:

 1500:com.typesafe.plugin.CommonsMailerPlugin 

UPDATE: I downloaded a sample project from https://github.com/playframework/play-mailer and tried to compile using sbt. This is not the same problem.

+6
source share
2 answers

It seems the problem is with the plugin version available in typeafe repo:

I built the plugin from sources, published it in my local repository, and then everything compiled perfectly.

The build.sbt sample application has:

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

Thus, it seems that the authors also had problems compiling the application using the plugin deployed in the official repository.

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

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

 1500:play.api.libs.mailer.CommonsMailerPlugin 

and then eveyrthing finally works

+4
source

README is updated with the latest development (future version). As of 12/19/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 access README in the v2.3.1 tag: https://github.com/playframework/play-mailer/tree/v2.3.1

For the upcoming version, we decided to break compatibility to move Play Mailer to our own package and provide a better implementation. This is the reason why the documentation in the main branch does not work with version 2.3.1.

+1
source

Source: https://habr.com/ru/post/978686/


All Articles