Method for processing the end of the tag.
Properties props = System.getProperties();
try {
if (host != null)
props.put("mail.smtp.host", host);
else if (props.getProperty("mail.smtp.host") == null)
props.put("mail.smtp.host", InetAddress.getLocalHost().
getHostName());
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
InternetAddress[] toAddrs = null, ccAddrs = null;
try {
if (recipients != null) {
toAddrs = InternetAddress.parse(recipients, false);
msg.setRecipients(Message.RecipientType.TO, toAddrs);
} else
throw new JspException("No recipient address specified");
if (sender != null)
msg.setFrom(new InternetAddress(sender));
else
throw new JspException("No sender address specified");
if (cc != null) {
ccAddrs = InternetAddress.parse(cc, false);
msg.setRecipients(Message.RecipientType.CC, ccAddrs);
}
if (subject != null)
msg.setSubject(subject);
if ((body = getBodyContent().getString()) != null)
msg.setText(body);
else
msg.setText("");
Transport.send(msg);
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
return(EVAL_PAGE);