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

Automatically add a template body part when creating a template message and add support for passing from/to/cc/bcc as parameters

    Details

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

      Description

      Instead of having to write:

            #set ($from = $services.mailsender.configuration.fromAddress)
            #if ("$!from" == '')
              #set ($from = "no-reply@${request.serverName}")
            #end
            #set ($mailTemplateReference = $services.model.createDocumentReference('', 'XWiki', 'ResetPasswordMailContent'))
            #set ($mailParameters = {'language' : $xcontext.language})
            #set ($message = $services.mailsender.createMessage('template', $mailTemplateReference, $mailParameters))
            #set ($discard = $message.setFrom($from))
            #set ($discard = $message.addRecipients('to', $userEmail))
            #set ($discard = $message.addPart("xwiki/template", $mailTemplateReference, $mailParameters))
            #set ($discard = $message.send())
      

      The idea is to be able to write:

            #set ($from = $services.mailsender.configuration.fromAddress)
            #if ("$!from" == '')
              #set ($from = "no-reply@${request.serverName}")
            #end
            #set ($mailTemplateReference = $services.model.createDocumentReference('', 'XWiki', 'ResetPasswordMailContent'))
            #set ($mailParameters = {'language' : $xcontext.language})
            #set ($message = $services.mailtemplatesender.createMessage($from, $userEmail, $mailTemplateReference, $mailParameters))
            #set ($discard = $message.send())
      

      That means going from 5 API calls to 2 API calls (for this specific use case)

        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: