Monday, February 4, 2013

Send e-mail using Play 2, Scala, and Emailer pluggin

I needed to send an e-mail when a user fills up a contact form. Below is the how I implemented the application using the mailer plugin.

First, we add the e-mailer library: projects/Build.scala

Then, we add the play plugin conf/play.plugins:

Now, you need to add the smtp host in conf/application.conf:

Now, we add the service:

From the controller, then I access this service:

It is using the Contact model which has the following fields:

The application needs to import the following:

Then, you can start building you e-mail service by using:

Where all the messages are stores in the conf/messages

1 comment: