Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-11701

Improve the mail sender script service API when sending mails to a group or to a list of users

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.4
    • Fix Version/s: 7.0-milestone-1, 6.4.1
    • Component/s: Mail
    • Labels:
      None
    • Tests:
      Integration
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      The problem is that we cannot implement new iterator factories that return Iterator<MimeMessage> and call them from the mail scripting API.

      The idea is to generify MimeMessageFactory to support creating Iterator<MimeMessage>.

      Current usage of sending a mail template to a group:

      ## Parameters for the 'template' MimeMessageFactory
      #set ($templateParameters = {'language' : $xcontext.language, 'velocityVariables' : { 'var1' : 'value1' }})
      
      ## Parameters for the 'group' MimeMessage Iterator Factory
      #set ($templateReference = $services.model.createDocumentReference('', 'Space', 'MailTemplatePage'))
      #set ($parameters = {'parameters' : $parameters, 'source' : $templateReference })
      
      #set ($groupReference = $services.model.createDocumentReference('', 'XWiki', 'MyGroup'))
      #set ($messages = $services.mailsender.createMessages('group', $groupReference, 'template', $parameters))
      #set ($mailResult = $services.mailsender.send($messages, 'database'))
      

      And when this issue is implemented:

      ## Parameters for the 'template' MimeMessageFactory
      #set ($templateParameters = {'language' : $xcontext.language, 'velocityVariables' : { 'var1' : 'value1' }})
      
      ## Parameters for the 'group' MimeMessageFactory
      #set ($templateReference = $services.model.createDocumentReference('', 'Space', 'MailTemplatePage'))
      #set ($groupParameters = {'hint' : 'template', 'parameters' : $templateParameters, 'source' : $templateReference })
      
      #set ($groupReference = $services.model.createDocumentReference('', 'XWiki', 'MyGroup'))
      #set ($messages = $services.mailsender.createMessages('group', $groupReference, $groupParameters))
      #set ($mailResult = $services.mailsender.send($messages, 'database'))
      

        Attachments

          Activity

            People

            • Assignee:
              vmassol Vincent Massol
              Reporter:
              vmassol Vincent Massol
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: