Skip to content

Silent error when an email template is not found #8437

Closed
@shavounet

Description

@shavounet

Preconditions

  1. Tested on Magento CE 2.1.3 with PHP 7

Steps to reproduce

  1. Create a custom controller, sending a custom mail, mostly like this
  2. Make a mistake in the template file name
  3. Try to send the mail

Expected result

  1. The mail is correctly sent with content

Actual result

  1. The mail is correctly sent but the body is empty

IMO, \Magento\Email\Model\AbstractTemplate::loadDefault should throw an error (or at least log an error message...), when the file is not found. In this case $rootDirectory->getRelativePath($templateFile) returns an empty string and so does $rootDirectory->readFile('')... Maybe the problem is deeper, but a silent error should not happen.

If it matters, my send code in the controller was followed by a redirect (after filling a form).

Best way to reproduce

  1. Go to file app/code/Magento/Customer/etc/email_templates.xml
  2. Make a mistake in the template file name: replace from account_new.html to account_new1.html in tag:
...
    <template id="customer_create_account_email_template" label="New Account" file="account_new1.html" type="html" module="Magento_Customer" area="frontend"/>
...
  1. Create new customer on frontend

Expected result

  1. The email about new customer not sent.
  2. Exception like "Can not find the file account_new1.htm" is present in logs

Actual result

  1. The mail is correctly sent but the body is empty
  2. Any exception is absent in logs.

Metadata

Metadata

Assignees

Labels

Fixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions