@Override public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context) { return new MailSenderPluginApi((MailSenderPlugin) plugin, context); }
@Override public int sendRawMessage(String from, String to, String rawMessage) { Mail email = new Mail(); email.setFrom(from); email.setTo(to); getProtectedPlugin().parseRawMessage(rawMessage, email); return sendMail(email); }
/** * {@inheritDoc} * * @see MailSender#sendMessageFromTemplate(String, String, String, String, String, String, VelocityContext) */ public int sendMessageFromTemplate(String from, String to, String cc, String bcc, String language, String documentFullName, VelocityContext vcontext) { try { return getProtectedPlugin().sendMailFromTemplate(documentFullName, from, to, cc, bcc, language, vcontext, this.context); } catch (Exception e) { // If the exception is a null pointer exception there is no message and e.getMessage() is null. if (e.getMessage() != null) { this.context.put("error", e.getMessage()); } LOG.error("sendMessageFromTemplate", e); return -1; } }
/** * {@inheritDoc} * * @see MailSender#sendTextMessage(String, String, String, String) */ public int sendTextMessage(String from, String to, String subject, String message) { Mail email = new Mail(); email.setSubject(subject); email.setTextPart(message); email.setFrom(from); email.setTo(to); return sendMail(email); }
emailService.sendMessageFromTemplate( sender, email, null, null, language, mailTemplate, vcontext);
@Override public int sendMessageFromTemplate(String from, String to, String cc, String bcc, String language, String documentFullName, VelocityContext vcontext) { try { return getProtectedPlugin().sendMailFromTemplate(documentFullName, from, to, cc, bcc, language, vcontext, this.context); } catch (Exception e) { // If the exception is a null pointer exception there is no message and e.getMessage() is null. if (e.getMessage() != null) { this.context.put("error", e.getMessage()); } LOGGER.error("sendMessageFromTemplate", e); return -1; } }
@Override public int sendTextMessage(String from, String to, String subject, String message) { Mail email = new Mail(); email.setSubject(subject); email.setTextPart(message); email.setFrom(from); email.setTo(to); return sendMail(email); }
/** * {@inheritDoc} * * @see MailSender#sendRawMessage(String, String, String) */ public int sendRawMessage(String from, String to, String rawMessage) { Mail email = new Mail(); email.setFrom(from); email.setTo(to); getProtectedPlugin().parseRawMessage(rawMessage, email); return sendMail(email); }
@Override public int sendMail(Mail mail) { int result = 0; try { getProtectedPlugin().sendMail(mail, this.context); } catch (Exception e) { // If the exception is a null pointer exception there is no message and e.getMessage() is null. if (e.getMessage() != null) { this.context.put("error", e.getMessage()); } LOGGER.error("Failed to send email [" + mail.toString() + "]", e); result = -1; } return result; }
@Override public int sendTextMessage(String from, String to, String cc, String bcc, String subject, String message, List<Attachment> attachments) { Mail email = new Mail(); email.setSubject(subject); email.setTextPart(message); email.setFrom(from); email.setTo(to); email.setCc(cc); email.setBcc(bcc); email.setAttachments(attachments); return sendMail(email); }
/** * {@inheritDoc} * * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#getPluginApi(XWikiPluginInterface, XWikiContext) */ @Override public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context) { return new MailSenderPluginApi((MailSenderPlugin) plugin, context); }
/** * Uses an XWiki document to build the message subject and context, based on variables stored in a map. Sends the * email. * * @param from Email sender * @param to Email recipient * @param cc Email Carbon Copy * @param bcc Email Hidden Carbon Copy * @param language Language of the email * @param documentFullName Full name of the template to be used (example: XWiki.MyEmailTemplate). The template needs * to have an XWiki.Email object attached * @param parameters variables to be passed to the velocity context * @return 0 on success, -1 on failure. On failure the error message is stored in the XWiki context under the * "error" key. */ public int sendMessageFromTemplate(String from, String to, String cc, String bcc, String language, String documentFullName, Map<String, Object> parameters) { try { return getProtectedPlugin().sendMailFromTemplate(documentFullName, from, to, cc, bcc, language, parameters, this.context); } catch (Exception e) { // If the exception is a null pointer exception there is no message and e.getMessage() is null. if (e.getMessage() != null) { this.context.put("error", e.getMessage()); } LOGGER.error("sendMessageFromTemplate", e); return -1; } }
@Override public int sendHtmlMessage(String from, String to, String cc, String bcc, String subject, String body, String alternative, List<Attachment> attachments) { Mail email = new Mail(); email.setSubject(subject); email.setFrom(from); email.setTo(to); email.setCc(cc); email.setBcc(bcc); email.setTextPart(alternative); email.setHtmlPart(body); email.setAttachments(attachments); return sendMail(email); }
@Override public int sendMail(Mail mail, MailConfiguration mailConfiguration) { int result = 0; try { getProtectedPlugin().sendMail(mail, mailConfiguration, this.context); } catch (Exception e) { // If the exception is a null pointer exception there is no message and e.getMessage() is null. if (e.getMessage() != null) { this.context.put("error", e.getMessage()); } LOGGER.error("Failed to send email [" + mail.toString() + "] using mail configuration [" + mailConfiguration.toString() + "]", e); result = -1; } return result; } }
/** * {@inheritDoc} * * @see MailSender#sendTextMessage(String, String, String, String, String, String, java.util.List) */ public int sendTextMessage(String from, String to, String cc, String bcc, String subject, String message, List<Attachment> attachments) { Mail email = new Mail(); email.setSubject(subject); email.setTextPart(message); email.setFrom(from); email.setTo(to); email.setCc(cc); email.setBcc(bcc); email.setAttachments(attachments); return sendMail(email); }
/** * {@inheritDoc} * * @see MailSender#sendMail(Mail) */ public int sendMail(Mail mail) { int result = 0; try { getProtectedPlugin().sendMail(mail, this.context); } catch (Exception e) { // If the exception is a null pointer exception there is no message and e.getMessage() is null. if (e.getMessage() != null) { this.context.put("error", e.getMessage()); } LOG.error("Failed to send email [" + mail.toString() + "]", e); result = -1; } return result; }
/** * {@inheritDoc} * * @see MailSender#sendHtmlMessage(String, String, String, String, String, String, String, java.util.List) */ public int sendHtmlMessage(String from, String to, String cc, String bcc, String subject, String body, String alternative, List<Attachment> attachments) { Mail email = new Mail(); email.setSubject(subject); email.setFrom(from); email.setTo(to); email.setCc(cc); email.setBcc(bcc); email.setTextPart(alternative); email.setHtmlPart(body); email.setAttachments(attachments); return sendMail(email); }
/** * {@inheritDoc} * * @see MailSender#sendMail(Mail, MailConfiguration) */ public int sendMail(Mail mail, MailConfiguration mailConfiguration) { int result = 0; try { getProtectedPlugin().sendMail(mail, mailConfiguration, this.context); } catch (Exception e) { // If the exception is a null pointer exception there is no message and e.getMessage() is null. if (e.getMessage() != null) { this.context.put("error", e.getMessage()); } LOG.error("Failed to send email [" + mail.toString() + "] using mail configuration [" + mailConfiguration.toString() + "]", e); result = -1; } return result; } }