All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.causecode.util.GenericEmailService.groovy Maven / Gradle / Ivy

Go to download

nucleus is a Grails-Groovy plugin which contains utility methods, classes and endpoints.

There is a newer version: 1.1.0
Show newest version
/*
 * Copyright (c) 2016, CauseCode Technologies Pvt Ltd, India.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or
 * without modification, are not permitted.
 */
package com.causecode.util

import grails.plugin.asyncmail.AsynchronousMailService
import org.springframework.mail.MailException

/**
 * This class is used for sending emails using the AsynchronousMailPlugin. It is a utility class that handles exception
 * while sending emails.
 *
 * @author Nikhil Sharma
 * @since 2.0.0
 */
class GenericEmailService {

    AsynchronousMailService asynchronousMailService

    boolean sendEmail(Closure closure, String eventName) {
        try {
            asynchronousMailService.sendMail(closure)
        } catch (MailException e) {
            log.warn "Error sending email for $eventName", e

            return false
        }

        return true
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy