mail.internet.InternetAddress;
import java.util.Properties;
import javax.servlet.ServletContext;
/**
* This class is responsible for sending e-mails.
*
* @author
Frank W. Zammetti.
*/
public class MailSender {
/**
* Log instance.
*/
private static Log log = LogFactory.getLog(MailSender.class);
/**
* This method sends a message.
*
* @param inTo The recipient of the message.
* @param inSubject The subject of the message.
* @param inText The text of the message.
* @return A string indicating success or failure.
*/
public String sendMessage(String inTo, String inSubject, String inText,
ServletContext sc) {
Transport transport = null;
FileOutputStream fos = null;
CHAPTER 4 n INSTAMAIL: AN AJAX-BASED WEBMAIL CLIENT 174
ObjectOutputStream oos = null;
String result = "";
try {
// Get the options, and also get the current date/time. We do it once
// here so just in case we cross a second boundary while processing,
// we know the file name and the sent time will jive.
OptionsDTO options = new OptionsManager().retrieveOptions(sc);
Date d = new Date();
log.info("options = " + options + "\n\n");
// Construct Properties JavaMail needs.
Pages:
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331