[MGNLMAIL-173] Cannot send template-based messages with "simple" render type Created: 02/Aug/23  Updated: 23/Oct/23  Resolved: 09/Aug/23

Status: Closed
Project: Magnolia Mail Module
Component/s: Backend
Affects Version/s: 5.6.0
Fix Version/s: 6.0.0, 5.6.1

Type: Bug Priority: Neutral
Reporter: Anh Vu Assignee: Anh Vu
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: 0d Remaining Estimate: 0d
Σ Time Spent: 4d 6.5h Time Spent: 4d 6.5h
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Attachments: PNG File Cannot-load-template-file.png     PNG File Error.png     PNG File Template-configuration.png     PNG File no-email-error.png     PNG File simple-mail-test.png     PNG File user-settings.png    
Issue Links:
dependency
is depended upon by MGNLPUR-222 Modify unit test after changes from mail Closed
relation
is related to MGNLMAIL-188 DOC: Update the guideline for creatin... Open
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLMAIL-174 Implement Sub-task Closed Anh Vu  
MGNLMAIL-175 Review Sub-task Closed Robert Šiška  
MGNLMAIL-176 piQA Sub-task Closed Robert Šiška  
MGNLMAIL-177 QA Sub-task Closed Oanh Thai Hoang  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Documentation update required:
Yes
Date of First Response:
Epic Link: DevX Bucket
Sprint: DevX 43
Story Points: 3
Team: DeveloperX
Work Started:
Approved:
Yes

 Description   

Currently as a user I cannot send emails with the template configuration which includes "simple" render type and a template file.

Steps to reproduce:

1. Configure SMTP server via Mail Tools app
2. Go to /modules/mail/config/templateConfiguration and then create a template configuration with type = simple and a specific templateFile = xxx (Refer to the Template-configuration.png attachment below)
3. Test the template using Mail Tools app.
(Go to Mail Tools -> Select Verify Setup tab -> Choose the template -> Click "SEND TEST EMAIL" button)

Expected result: The email based on the configured template file is sent successfully.
Actual result: The email is not sent, the error message "Unable to send email: null." is displayed. (Refer to the Error.png attachment below)

For Mail configuration and testing refer to: Mail module



 Comments   
Comment by Richard Gange [ 02/Aug/23 ]

Hey anh.vu-

It worked for me ok.

I think the problem here is the error message isn't very helpful. What that is indicating is whichever user you are logged in as doesn't have their email set in their profile.

What you can do is use the Security App or the User Setting dialog (top right corner) to set your email address. For example, I set mine in the superuser:

HTH
Rich

Comment by Anh Vu [ 02/Aug/23 ]

Hi rgange,
If I don't have email in my profile, I will get an error "Current user has no email address set in their profile". 
In my case, I do have an email and I can send a simple email without template file. 
The issue happens when I try to send the email with a template file. Did you configure a template file when testing it? I mean the "templateFile" property, you can refer to the Template-configuration.png attachment.
I have updated the description to make it clearer.
Thank you

Comment by Richard Gange [ 02/Aug/23 ]

Ah ok, yes, now it's clear. I can reproduce it.

From my point of view we should change this line:

URL url = this.getClass().getResource("/" + template.getTemplateFile());

It seems really old skool to be doing it this way.

Maybe something like:

InputStream templateFile = Components.getComponent(ResourceLinker.class).getResource(template.getTemplateFile()).openStream();

would be better...

Comment by Richard Gange [ 02/Aug/23 ]

anh.vu this commit fixed it for me.

Update: I had to do a second commit for my unused imports :facepalm:

Comment by Anh Vu [ 03/Aug/23 ]

rgange Thank you for your support

Generated at Mon Feb 12 06:04:18 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.