Class MailSenderPlugin

    • Method Detail

      • parseAddresses

        public static String[] parseAddresses​(String email)
        Split comma separated list of emails
        Parameters:
        email - comma separated list of emails
        Returns:
        An array containing the emails
      • createAttachmentBodyPart

        public javax.mail.internet.MimeBodyPart createAttachmentBodyPart​(Attachment attachment,
                                                                         XWikiContext context)
                                                                  throws XWikiException,
                                                                         IOException,
                                                                         javax.mail.MessagingException
        Add attachments to a multipart message
        Parameters:
        attachment - the attachment to create the body part for.
        context - the XWiki context.
        Returns:
        the body part for the given attachment.
        Throws:
        XWikiException
        IOException
        javax.mail.MessagingException
      • createMimeMultipart

        public javax.mail.Multipart createMimeMultipart​(Mail mail,
                                                        XWikiContext context)
                                                 throws javax.mail.MessagingException,
                                                        XWikiException,
                                                        IOException
        Creates a Multipart MIME Message (multiple content-types within the same message) from an existing mail
        Parameters:
        mail - The original Mail
        Returns:
        The Multipart MIME message
        Throws:
        javax.mail.MessagingException
        XWikiException
        IOException
      • parseRawMessage

        protected void parseRawMessage​(String rawMessage,
                                       Mail toMail)
        Splits a raw mail into headers and the actual content, filling in a Mail object. This method should be compliant with RFC 2822 as much as possible. If the message accidentally starts with what looks like a mail header, then that line WILL be considered a header; no check on the semantics of the header is performed.
        Parameters:
        rawMessage - the raw content of the message that should be parsed
        toMail - the Mail to create
        Throws:
        IllegalArgumentException - if the target Mail or the content to parse are null or the empty string
      • evaluate

        protected String evaluate​(String property,
                                  org.apache.velocity.context.Context context)
                           throws Exception
        Evaluates a String property containing Velocity
        Parameters:
        property - The String property
        context - Context of the request
        Returns:
        The evaluated String
        Throws:
        Exception
      • getFileName

        protected String getFileName​(String path)
        Get a file name from its path
        Parameters:
        path - The file path
        Returns:
        The file name
      • prepareVelocityContext

        public org.apache.velocity.VelocityContext prepareVelocityContext​(String fromAddr,
                                                                          String toAddr,
                                                                          String ccAddr,
                                                                          String bccAddr,
                                                                          org.apache.velocity.VelocityContext vcontext,
                                                                          XWikiContext context)
        Prepares a Mail Velocity context
        Parameters:
        fromAddr - Mail from
        toAddr - Mail to
        ccAddr - Mail cc
        bccAddr - Mail bcc
        vcontext - The Velocity context to prepare
        Returns:
        The prepared context
      • prepareVelocityContext

        public org.apache.velocity.VelocityContext prepareVelocityContext​(String fromAddr,
                                                                          String toAddr,
                                                                          String ccAddr,
                                                                          String bccAddr,
                                                                          Map<String,​Object> parameters,
                                                                          XWikiContext context)
        Prepares a Mail Velocity context based on a map of parameters
        Parameters:
        fromAddr - Mail from
        toAddr - Mail to
        ccAddr - Mail cc
        bccAddr - Mail bcc
        parameters - variables to be passed to the velocity context
        Returns:
        The prepared context
      • sendMailFromTemplate

        public int sendMailFromTemplate​(String templateDocFullName,
                                        String from,
                                        String to,
                                        String cc,
                                        String bcc,
                                        String language,
                                        org.apache.velocity.VelocityContext vcontext,
                                        XWikiContext context)
                                 throws XWikiException
        Uses an XWiki document to build the message subject and context, based on variables stored in the VelocityContext. Sends the email.
        Parameters:
        templateDocFullName - Full name of the template to be used (example: XWiki.MyEmailTemplate). The template needs to have an XWiki.Email object attached
        from - Email sender
        to - Email recipient
        cc - Email Carbon Copy
        bcc - Email Hidden Carbon Copy
        language - Language of the email
        vcontext - Velocity context passed to the velocity renderer
        Returns:
        True if the email has been sent
        Throws:
        XWikiException
      • sendMailFromTemplate

        public int sendMailFromTemplate​(String templateDocFullName,
                                        String from,
                                        String to,
                                        String cc,
                                        String bcc,
                                        String language,
                                        Map<String,​Object> parameters,
                                        XWikiContext context)
                                 throws XWikiException
        Uses an XWiki document to build the message subject and context, based on variables stored in a map. Sends the email.
        Parameters:
        templateDocFullName - Full name of the template to be used (example: XWiki.MyEmailTemplate). The template needs to have an XWiki.Email object attached
        from - Email sender
        to - Email recipient
        cc - Email Carbon Copy
        bcc - Email Hidden Carbon Copy
        language - Language of the email
        parameters - variables to be passed to the velocity context
        Returns:
        True if the email has been sent
        Throws:
        XWikiException