Book Image

Play Framework Cookbook - Second Edition

By : Alexander Reelsen, Giancarlo Inductivo
Book Image

Play Framework Cookbook - Second Edition

By: Alexander Reelsen, Giancarlo Inductivo

Overview of this book

<p>As web and mobile systems become more sophisticated, anchoring systems in a mature, solid framework has become increasingly important. Play 2 provides developers with the necessary tools to build robust web applications.</p> <p>This book is a compilation of useful recipes aimed at helping developers discover the power of Play 2. The introductory section serves as a primer to Play Framework, wherein all the fundamentals of the framework are covered extensively. It then explains the usage of controllers and how modules can be leveraged for optimal performance. Next, the book walks you through creating and using APIs, followed by extensive real-world applications. Finally, you will learn to manage applications post production.</p>
Table of Contents (15 chapters)
Play Framework Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Utilizing play-mailer


For this recipe, we will explore how Play applications can send e-mails. We will use the Play module play-mailer to achieve this. We will be utilizing Mandrill, a cloud e-mailer service, to send out e-mails. For more information about Mandrill, please refer to https://mandrill.com/.

How to do it…

For Java, we need to take the following steps:

  1. Run the foo_java application with Hot-Reloading enabled:

        activator "~run"
    
  2. Declare play-mailer as a project dependency in build.sbt:

        "com.typesafe.play.plugins" %% "play-plugins-mailer" % "2.3.1"
  3. Enable the play-mailer plugin by declaring it in foo_java/conf/play.plugins:

        1500:com.typesafe.plugin.CommonsMailerPlugin
  4. Specify your smtp host information in foo_java/conf/application.conf:

        smtp.host=smtp.mandrillapp.com
        smtp.port=25
        smtp.user="YOUR OWN USER HERE"
        smtp.password="YOUR OWN PASSWORD HERE"
        smtp.mock=true
  5. Modify foo_java/app/controllers/Application.java by adding the following code:

        import play.libs...