01: package org.manentia.kasai.util;
02:
03: import java.util.ResourceBundle;
04:
05: import javax.mail.MessagingException;
06: import javax.mail.internet.AddressException;
07:
08: import org.manentia.kasai.Constants;
09:
10: /**
11: *
12: * @author rzuasti
13: */
14: public class MailUtil {
15:
16: public static void send(String subject, String message,
17: String recipient) throws AddressException,
18: MessagingException {
19: ResourceBundle res = ResourceBundle
20: .getBundle(Constants.CONFIG_PROPERTY_FILE);
21:
22: com.manentia.commons.mail.MailUtil.send(formatSubject(subject),
23: formatBody(message), recipient, true, res
24: .getString("mail.from"), res
25: .getString("mail.replyTo"), res
26: .getString("mail.smtp.host"), res
27: .getString("mail.smtp.user"), res
28: .getString("mail.smtp.password"));
29: }
30:
31: public static void send(String subject, String message,
32: String[] recipients) throws AddressException,
33: MessagingException {
34: ResourceBundle res = ResourceBundle
35: .getBundle(Constants.CONFIG_PROPERTY_FILE);
36:
37: com.manentia.commons.mail.MailUtil.send(formatSubject(subject),
38: formatBody(message), recipients, true, res
39: .getString("mail.from"), res
40: .getString("mail.replyTo"), res
41: .getString("mail.smtp.host"), res
42: .getString("mail.smtp.user"), res
43: .getString("mail.smtp.password"));
44: }
45:
46: private static String formatSubject(String subject) {
47: ResourceBundle messages = ResourceBundle
48: .getBundle(Constants.MESSAGES_PROPERTY_FILE);
49:
50: return messages.getString("mails.subjectPrefix") + subject;
51: }
52:
53: private static String formatBody(String body) {
54: ResourceBundle messages = ResourceBundle
55: .getBundle(Constants.MESSAGES_PROPERTY_FILE);
56:
57: return body + messages.getString("mails.signature");
58: }
59:
60: }
|