} catch (Exception e) {
Logger.warn(EmailFactory.class, "sendForm: Couldn't save the email backup in " + Config.getStringProperty("EMAIL_BACKUPS"));
}
// send the mail out;
Mailer m = new Mailer();
m.setToEmail(to);
m.setFromEmail(from);
m.setFromName(fromName);
m.setCc(cc);
m.setBcc(bcc);
m.setSubject(subject);
if (html) {
if(UtilMethods.isSet(emailBodies.get("emailHTMLBody")))
m.setHTMLBody(emailBodies.get("emailHTMLBody"));
else
m.setHTMLBody(emailBodies.get("emailHTMLTableBody"));
}
m.setTextBody(emailBodies.get("emailPlainTextBody"));
//Attaching files requested to be attached to the email
if(attachFiles != null) {
attachFiles = "," + attachFiles.replaceAll("\\s", "") + ",";
for(Entry<String, Object> entry : parameters.entrySet()) {
if(entry.getValue() instanceof File && attachFiles.indexOf("," + entry.getKey() + ",") > -1) {
File f = (File)entry.getValue();
m.addAttachment(f, entry.getKey() + "." + UtilMethods.getFileExtension(f.getName()));
}
}
}
if (m.sendMessage()) {
// there is an auto reply, send it on
if ((UtilMethods.isSet((String)getMapValue("autoReplyTemplate", parameters)) ||
UtilMethods.isSet((String)getMapValue("autoReplyText", parameters)))
&& UtilMethods.isSet((String)getMapValue("autoReplySubject", parameters))
&& UtilMethods.isSet((String)getMapValue("autoReplyFrom", parameters))) {
templatePath = (String) getMapValue("autoReplyTemplate", parameters);
if(UtilMethods.isSet(templatePath)) {
try {
emailBodies = buildEmail(templatePath, host, orderedMap, prettyVariableNamesMap, filesLinks.toString(), ignoreString, user);
} catch (Exception e) {
Logger.error(EmailFactory.class, "sendForm: Couldn't build the auto reply email body text. Sending plain text.", e);
}
}
m = new Mailer();
String autoReplyTo = (String)(getMapValue("autoReplyTo", parameters) == null?getMapValue("from", parameters):getMapValue("autoReplyTo", parameters));
m.setToEmail(UtilMethods.replace(autoReplyTo, "spamx", ""));
m.setFromEmail(UtilMethods.replace((String)getMapValue("autoReplyFrom", parameters), "spamx", ""));
m.setSubject((String)getMapValue("autoReplySubject", parameters));
String autoReplyText = (String)getMapValue("autoReplyText", parameters);
boolean autoReplyHtml = getMapValue("autoReplyHtml", parameters) != null?Parameter.getBooleanFromString((String)getMapValue("autoReplyHtml", parameters)):html;
if (autoReplyText != null)
{
if(autoReplyHtml)
{
m.setHTMLBody((String)getMapValue("autoReplyText", parameters));
} else {
m.setTextBody((String)getMapValue("autoReplyText", parameters));
}
}
else
{
if (autoReplyHtml)
{
if(UtilMethods.isSet(emailBodies.get("emailHTMLBody")))
m.setHTMLBody(emailBodies.get("emailHTMLBody"));
else
m.setHTMLBody(emailBodies.get("emailHTMLTableBody"));
}
m.setTextBody(emailBodies.get("emailPlainTextBody"));
}
m.sendMessage();
}
} else {
if(formBean != null){
try {
HibernateUtil.delete(formBean);