Show Navigation


The Novamail plug-in provides e-mail sending and retrieving capabilities to a Grails application. It is also capable of sending emails asynchronously by using a scheduled Job

Owner: novadge | 0.1.8 | May 25, 2020 | Package | Issues | Source | License: Apache-2.0

dependencies {
    compile 'com.novadge.plugins:novamail:0.1.8'



Build Status


The Novamail plug-in provides e-mail sending and receiving capabilities to a Grails application. It is also capable of sending emails asynchronously by using a scheduled Job.


I recommend you add the following to application.groovy config file. Please create the file if it doesn't exist.

Add your email provider properties to grails configuration file: Example Assuming you want to add config for a gmail account for '[email protected]' then add the following to your grails config file.

novamail.hostProps = [

  ["": "imaps"],
  ["mail.imap.socketFactory.class": ""],
  ["mail.imap.socketFactory.fallback": "false"],
  ["mail.mime.address.strict": "false"],
  ["mail.smtp.starttls.enable": "true"],
  ["": ""],
  ["mail.smtp.auth": "true"],
  ["mail.smtp.socketFactory.port": "465"],
  ["mail.smtp.socketFactory.class": ""],
  ["mail.smtp.socketFactory.fallback": "false"]


       hostname= System.getenv("CS_HOSTNAME")
       username= System.getenv("CS_USERNAME")
       password= System.getenv("CS_PASSWORD")
       store= System.getenv("CS_STORE")

Avoid having passwords in your code. Store them as Environment variables.

Side note

Novamail will try to use predefined host props for some popular email providers if you do not provide hostProps


Inject messagingService into your class

def messagingService

messagingService is a Grails service that provides a single method called sendEmail that takes parameters. Please note that 'sendEmail()' is overloaded 'see' and can take various variations of parameters.

One simple form is: sendEmail(Map map)

Where ......

map contains parameters... Email recipient eg [email protected]

map.subject: "Your email subject"

map.body: "The body of your message"


An example usage can be seen below.

Class YourController{
    def messagingService
    def yourMethod(){
        def map = [to:"[email protected]",subject:"Email subject",body:"email body"]


Second form


To use the messagingService with mapped parameters, you need to declare a map with the required variables. These are, hostname, username, password, from, to, subject, body, html, attachments, hostProps


  • hostname : String
  • username: Stiring
  • password : String
  • from : String
  • to : String
  • subject : String
  • body : String
  • html : boolean
  • attachments : List

html is boolean that defaults to true,

attachments is a List of type File (for file attachments) and is optional, and

hostProps is a map of host properties (see above).

If hostname, username, password, from, hostProps have been set in the Config.groovy file, they do not have to be added to your map parameter. html defaults to true so that can be omitted as well except when set explicitly (your choice).

Example Usage

Class MyController {
    def messagingService
    def myMethod() {
        def map = [username:"[email protected]", password:"john_password", from:"JOHN Doe<[email protected]>", to: "[email protected]", subject: "Hello there!", body: "Just to test out awesome Novamail"]
        messagingService.sendEmail(map) // Call the messagingService sendEmail method passing in the map