package org.notificationengine.mail;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.log4j.Logger;
import org.notificationengine.constants.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailException;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Component;

@Component(value=Constants.MAILER)
public class Mailer {

	private static Logger LOGGER = Logger.getLogger(Mailer.class);
	
	@Autowired
	private MailSender mailSender;
	
	@Autowired
	private SimpleMailMessage templateMessage;

	public void sendMail(String recipientAddress, String text) {

        SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
        
        msg.setTo(recipientAddress);
        
        msg.setText(text);
        
        try{
            this.mailSender.send(msg);
        }
        catch(MailException ex) {
        	LOGGER.error(ExceptionUtils.getFullStackTrace(ex));
			
			LOGGER.error("Unable to send mail");
        }
    }
	
	public MailSender getMailSender() {
		return mailSender;
	}

	public void setMailSender(MailSender mailSender) {
		this.mailSender = mailSender;
	}

	public SimpleMailMessage getTemplateMessage() {
		return templateMessage;
	}

	public void setTemplateMessage(SimpleMailMessage templateMessage) {
		this.templateMessage = templateMessage;
	}
	
	
}

@@ -716,16 +716,83 @@
 ext) %7B%0A%0A
+%09%09// TODO enable customization of subject, and maybe from field%0A%09%09%0A
         
@@ -1047,16 +1047,129 @@
 n ex) %7B%0A
+        %09%0A        %09// TODO raise an exception so that the decorated notification is not marked as sent%0A        %09%0A
         

Add todo in mailer