use of org.olat.core.util.mail.MailContent in project OpenOLAT by OpenOLAT.
the class MailManagerImpl method makeMailBundle.
@Override
public MailBundle makeMailBundle(MailContext ctxt, Identity recipientTO, MailTemplate template, Identity sender, String metaId, MailerResult result) {
MailBundle bundle;
if (MailHelper.isDisabledMailAddress(recipientTO, result)) {
// email disabled, nothing to do
bundle = null;
} else {
MailContent msg = createWithContext(recipientTO, template, result);
if (msg != null && result.getReturnCode() == MailerResult.OK) {
// send mail
bundle = new MailBundle();
bundle.setContext(ctxt);
bundle.setFromId(sender);
bundle.setToId(recipientTO);
bundle.setMetaId(metaId);
bundle.setContent(msg);
} else {
bundle = null;
}
}
return bundle;
}
use of org.olat.core.util.mail.MailContent in project OpenOLAT by OpenOLAT.
the class MailManagerImpl method decorateMail.
protected MailContent decorateMail(MailBundle bundle) {
MailContent content = bundle.getContent();
String template = getMailTemplate();
boolean htmlTemplate = StringHelper.isHtml(template);
String body = content.getBody();
boolean htmlContent = StringHelper.isHtml(body);
if (htmlTemplate && !htmlContent) {
body = body.replace("&", "&");
body = body.replace("<", "<");
body = body.replace("\n", "<br />");
}
VelocityContext context = new VelocityContext();
context.put("content", body);
context.put("footer", MailHelper.getMailFooter(bundle));
context.put("server", Settings.getServerContextPathURI());
StringWriter writer = new StringWriter(2000);
MailerResult result = new MailerResult();
evaluate(context, template, writer, result);
String decoratedBody;
if (result.isSuccessful()) {
decoratedBody = writer.toString();
} else {
decoratedBody = content.getBody();
}
return new SimpleMailContent(content.getSubject(), decoratedBody, content.getAttachments());
}
use of org.olat.core.util.mail.MailContent in project openolat by klemens.
the class MailManagerImpl method makeMailBundle.
@Override
public MailBundle makeMailBundle(MailContext ctxt, Identity recipientTO, MailTemplate template, Identity sender, String metaId, MailerResult result) {
MailBundle bundle;
if (MailHelper.isDisabledMailAddress(recipientTO, result)) {
// email disabled, nothing to do
bundle = null;
} else {
MailContent msg = createWithContext(recipientTO, template, result);
if (msg != null && result.getReturnCode() == MailerResult.OK) {
// send mail
bundle = new MailBundle();
bundle.setContext(ctxt);
bundle.setFromId(sender);
bundle.setToId(recipientTO);
bundle.setMetaId(metaId);
bundle.setContent(msg);
} else {
bundle = null;
}
}
return bundle;
}
use of org.olat.core.util.mail.MailContent in project openolat by klemens.
the class MailManagerImpl method decorateMail.
protected MailContent decorateMail(MailBundle bundle) {
MailContent content = bundle.getContent();
String template = getMailTemplate();
boolean htmlTemplate = StringHelper.isHtml(template);
String body = content.getBody();
boolean htmlContent = StringHelper.isHtml(body);
if (htmlTemplate && !htmlContent) {
body = body.replace("&", "&");
body = body.replace("<", "<");
body = body.replace("\n", "<br />");
}
VelocityContext context = new VelocityContext();
context.put("content", body);
context.put("footer", MailHelper.getMailFooter(bundle));
context.put("server", Settings.getServerContextPathURI());
StringWriter writer = new StringWriter(2000);
MailerResult result = new MailerResult();
evaluate(context, template, writer, result);
String decoratedBody;
if (result.isSuccessful()) {
decoratedBody = writer.toString();
} else {
decoratedBody = content.getBody();
}
return new SimpleMailContent(content.getSubject(), decoratedBody, content.getAttachments());
}
Aggregations