KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > mail > handlers > SimpleMailHandler


1 package info.magnolia.cms.mail.handlers;
2
3 import info.magnolia.cms.mail.templates.MgnlEmail;
4
5 import java.util.Arrays JavaDoc;
6
7 import javax.mail.Transport JavaDoc;
8
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11
12
13 /**
14  * This is a simple util class to send email from the form pages ... This class was previously included inside the jsp
15  * related to the form.
16  * @author niko
17  * @version $Id $
18  */

19 public class SimpleMailHandler implements MgnlMailHandler {
20
21     /**
22      * Logger
23      */

24     private static Logger log = LoggerFactory.getLogger(SimpleMailHandler.class);
25
26     public synchronized void prepareAndSendMail(MgnlEmail email) throws Exception JavaDoc {
27         email.setBody();
28         sendMail(email);
29     }
30
31     public synchronized void sendMail(MgnlEmail email) throws Exception JavaDoc {
32         Transport.send(email);
33         log.info("Mail has been sent to: {}", Arrays.asList(email.getAllRecipients()));
34     }
35 }
36
Popular Tags