1 package org.manentia.kasai.util; 2 3 import java.util.ResourceBundle ; 4 5 import javax.mail.MessagingException ; 6 import javax.mail.internet.AddressException ; 7 import org.manentia.kasai.*; 8 9 13 public class MailUtil { 14 15 public static void send(String subject, String message, String recipient) 16 throws AddressException , MessagingException { 17 ResourceBundle res = ResourceBundle.getBundle(Constants.PROPERTY_FILE); 18 19 com.koala.commons.mail.MailUtil.send(formatSubject(subject), formatBody(message), recipient, true, res.getString("mail.from"), 20 res.getString("mail.replyTo"), res.getString("mail.smtp.host"), 21 res.getString("mail.smtp.user"), res.getString("mail.smtp.password")); 22 } 23 24 public static void send(String subject, String message, String [] recipients) 25 throws AddressException , MessagingException { 26 ResourceBundle res = ResourceBundle.getBundle(Constants.PROPERTY_FILE); 27 28 com.koala.commons.mail.MailUtil.send(formatSubject(subject), formatBody(message), recipients, true, res.getString("mail.from"), 29 res.getString("mail.replyTo"), res.getString("mail.smtp.host"), 30 res.getString("mail.smtp.user"), res.getString("mail.smtp.password")); 31 } 32 33 private static String formatSubject(String subject){ 34 ResourceBundle messages = ResourceBundle.getBundle(Constants.MESSAGES); 35 36 return messages.getString("mails.subjectPrefix") + subject; 37 } 38 39 private static String formatBody(String body){ 40 ResourceBundle messages = ResourceBundle.getBundle(Constants.MESSAGES); 41 42 return body + messages.getString("mails.signature"); 43 } 44 45 } 46 | Popular Tags |