Parameters parameters)
throws Exception {
boolean success = false;
Map status = null;
MailSender mms = null;
try {
Request request = ObjectModelHelper.getRequest(objectModel);
// FIXME Remove support of old smtphost parameter
String smtpHost = parameters.getParameter("smtp-host", parameters.getParameter("smtphost", this.smtpHost));
String smtpUser = parameters.getParameter("smtp-user", this.smtpUser);
String smtpPassword = parameters.getParameter("smtp-password", this.smtpPassword);
// Empty parameter means absent parameter
if ("".equals(smtpHost)) {
smtpHost = this.smtpHost;
}
if ("".equals(smtpUser)) {
smtpUser = this.smtpUser;
}
if ("".equals(smtpPassword)) {
smtpPassword = this.smtpPassword;
}
mms = (MailSender) this.manager.lookup(MailSender.ROLE);
// Initialize non-default session if host or user specified.
if (smtpHost != null || smtpUser != null) {
mms.setSmtpHost(smtpHost, smtpUser, smtpPassword);
}
if (parameters.isParameter("from")) {
mms.setFrom(parameters.getParameter("from", null));
}
if (parameters.isParameter("to")) {
mms.setTo(parameters.getParameter("to", null));
}
if (parameters.isParameter("replyTo")) {
mms.setReplyTo(parameters.getParameter("replyTo", null));
}
if (parameters.isParameter("cc")) {
mms.setCc(parameters.getParameter("cc", null));
}
if (parameters.isParameter("bcc")) {
mms.setBcc(parameters.getParameter("bcc", null));
}
if (parameters.isParameter("subject")) {
mms.setSubject(parameters.getParameter("subject", null));
}
if (parameters.isParameter("charset")) {
mms.setCharset(parameters.getParameter("charset", null));
}
if (parameters.isParameter("src")) {
mms.setBodyFromSrc(parameters.getParameter("src", null));
if (parameters.isParameter("srcMimeType")) {
mms.setBodyFromSrcMimeType(
parameters.getParameter("srcMimeType", null));
}
} else if (parameters.isParameter("body")) {
mms.setBody(parameters.getParameter("body", null));
}
if (parameters.isParameter("attachments")) {
String fileName[] = StringUtils.split(parameters.getParameter("attachments"));
for (int i = 0; i < fileName.length; i++) {
String srcName = fileName[i];
if (srcName.indexOf(":") == -1) {
Object obj = request.get(srcName);
mms.addAttachment(obj);
if (getLogger().isDebugEnabled()) {
getLogger().debug("request-attachment: " + obj);
}
} else {
mms.addAttachmentURL(srcName,
null,
srcName.substring(srcName.lastIndexOf('/') + 1));
if (getLogger().isDebugEnabled()) {
getLogger().debug("sitemap-attachment: " + srcName);
}
}
}
}
mms.send();
success = true;
status = new HashMap(3);
status.put(Sendmail.STATUS, "success");