Uploaded image for project: 'Magnolia Mail Module'
  1. Magnolia Mail Module
  2. MGNLMAIL-47

MailTemplate configured parameters replaced by context parameters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 5.1.4, 5.2.2
    • None
    • Backend, Templates
    • None

    Description

      Maybe there is a bug in mail module working with parameters.

      If you define a template with some parameters in mail module configuration and then you send an email replacing those parameters you lost the original values until you reload mail module.

      The problem depends on the method getTemplate(String templateName) in MgnlMailFactory; BeanUtils.cloneBean(...) creates a shallow clone of the original MailTemplate object, so if we modify the parameters map in the cloned bean we are effectively working on the original Map.
      I think the same happens with attachmentes

      To reproduce

      • Create simple freemarker template

        Param1: ${param1!'Not defined'}
        Param2: ${param2!'Not defined'}
        Param3: ${param3!'Not defined'}

      • Configure the template under /modules/mail/config/templatesConfiguration

        myTemplate

        • parameters
          • param1 => Param1
          • param2 => Param2
          • param3 => Param3
        • from => ...
        • subject => ...
        • templateFile => path of the new template
        • type => freemarker
      • Use Tools -> Mail to send a test email using the new template myTemplate, without setting parameters
      • Send another mail setting the parameter param1 (param1=My test parameter)
      • Send another mail wihtout parameters

      The first and the second email are correct. In the third email param1 has value "My test parameter" insted of "Param1"

      A simple patch is attached

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              rsiska Robert Šiška
              mcollovati Marco Collovati
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD