1- Create a new play application in scala
> play new background-email2- Let's set the Global object location for our project. In your background-email/conf/application.conf file, make sure you have the following set:
application.global=GlobalThis will tell Play where to look for the Global object class of our application.
3- Under background-email/app/ create Global.scala. This file is loaded at application start time and the onStart method is where we can add calls to schedule tasks. In the example below, we'll have onStart call startAwesomeBackgroundTask which will schedule periodic email sends. Note: If you want this example to work, create a gmail account and replace "firstname.lastname@example.org" with your username and "password" with a the real password.
4- Before we can run our code, we'll need to add the right dependencies to our project. Update background-email/project/Build.scala to include a reference to org.codemonkey.simplejavamail:
5- You should now be able to run the application and see it in action:
> play start
Voila! From the console output you should be seeing an email sent every 5 seconds. The proof is in the pudding:
*The above instructions work as of Play 2.1.2.