@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; } }
/** * {@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; } }
@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; }
/** * 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; } }
/** * {@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; }
@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#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; } }
@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#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); }