[MGNLMAIL-40] When using ${type} and ${contentType} in the Form component E-Mail text, these values get overwritten. Created: 06/Nov/13 Updated: 24/Mar/22 |
|
| Status: | Open |
| Project: | Magnolia Mail Module |
| Component/s: | Backend, Templates |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Christian Balaguer | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | maintenance | ||
| Remaining Estimate: | 0d | ||
| Time Spent: | 1h | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Release notes required: |
Yes
|
| Documentation update required: |
Yes
|
| Date of First Response: |
| Description |
|
To reproduce:
The problem lies in the method info.magnolia.module.mail.MgnlMailFactory#getEmailFromType
Map<String, Object> newParams = new HashMap<String, Object>();
newParams.putAll(params);
if(!StringUtils.isEmpty(type)) {
newParams.put(MailTemplate.MAIL_TYPE, type);
}
if(!StringUtils.isEmpty(contentType)) {
newParams.put(MailTemplate.MAIL_CONTENT_TYPE, contentType);
}
return getEmail(newParams, attachments);
Here the parameters are overwritten, with the put() method. The contentType param may not be that big of a problem, but recently one of our customers named one of its form fields "type" and was surprised to always get "freemarker" as value in the email text. Improvement expectation: |
| Comments |
| Comment by Tobias Mattsson [ 04/Dec/13 ] |
|
Moved to MGNLMAIL, the original affects version was 4.5.11. |
| Comment by Viet Nguyen [ 03/Aug/18 ] |
|
We'll update our documentation regarding using of 'type' and 'contentType' in email template. Let's consider them as our provided 'context' objects which should not be used by end users. |
| Comment by Viet Nguyen [ 09/Aug/18 ] |
|
All params will be 'merged' with MailTemplate.setValues(Map<String, Object>, List<MailAttachment>) contentType,from,subject,to,mailTo,cc,type,parameters,attachments,body,html,templateFile,replyTo,bcc,username,password This is Mail module current implementation, we can consider an improvement to support overlapping of parameter names resolution, for convenience, we'll directly change this ticket into an improvement ticket and update our documentation accordingly. |