-
Bug
-
Resolution: Fixed
-
Major
-
None
-
None
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
- parameters
- 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