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

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 6.2-milestone-1
    • 6.0
    • Mail
    • None
    • Unit, Integration
    • Unknown

    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

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

            Dates

              Created:
              Updated:
              Resolved: