Email template overrides
What it does
WebForms 4 writes the text of each notification inside the notification itself, so most of its mail no longer comes from a Magento email template. A few templates are still rendered through Magento's email system, and those you override the usual way: a file of the same name in your theme. This page lists them, says what each one must keep, and how notification content written before WebForms 4 is handled.
Templates WebForms renders
All are declared in etc/email_templates.xml of the WebForms module and live in view/frontend/email/.
| Template id | File | What it is |
|---|---|---|
webforms_wrapper_thread | wrapper/thread.html | Helpdesk Style: the frame around a notification with Content Source set to Standard Content, saved in the admin. The store name on top, then the message |
webforms_wrapper_store | wrapper/store.html | Store Template: a card with the email logo, the form's name and a "Sent by" line. Used only for a notification whose stored design is store, which the admin editor doesn't set (see Limits) |
webforms_inbound_probe | inbound_probe.html | The test message the inbound mailbox check sends to itself |
webforms_inbound_unmatched | inbound_unmatched.html | The notice sent when an incoming reply belongs to no submission |
webforms_result_print | result_print.html | The PDF layout of WebForms 3, used only when a form has no PDF document bound. The print and download links refuse in that case, so a store normally never reaches it |
The other ids in the file (webforms_notification, webforms_admin_notification,
webforms_customer_notification, webforms_admin_reply_for_customer, webforms_customer_reply_for_admin,
webforms_result_approval, webforms_result_status, webforms_assignment_notification) are the WebForms 3
notification templates. Nothing sends mail through them any more
(MageMe\WebForms\Model\Notification\Render\TargetRenderer refuses a revision that points at one). They stay
registered so that the upgrade can read them; see Content from WebForms 3.
Before you start
- A theme of your own, assigned to the store view in Content → Design → Configuration. See Theme and template overrides.
- File access to the store and a shell where you can run
bin/magento. - A copy saved in Marketing → Communications → Email Templates doesn't work here. WebForms asks Magento for
these templates by their string id, and Magento loads a saved copy only by its numeric id
(
Magento\Email\Model\Template::processTemplate()), so the file in the theme is the only override.
Steps
Override the Helpdesk Style frame
-
Copy
view/frontend/email/wrapper/thread.htmlfrom the WebForms module (vendor/mageme/module-webforms-base/for a Composer install,app/code/MageMe/WebForms/for a copy inapp/code) into your theme, keeping the path belowemail/:app/design/frontend/Northstar/furniture/MageMe_WebForms/email/wrapper/thread.html -
Edit the copy. Keep
{{var body_slot}}exactly once: the notification's message replaces it. Keep the<!--wf:reply-line-->marker in front of it: an answerable email puts its "reply above this line" text there. -
Clean the cache:
bin/magento cache:clean -
Send a test from a notification that uses Standard Content. See Test and switch on an email.
The frame is rendered with Magento's full template filter in the store's frontend design, so directives such as
{{trans}}, {{if}} and {{inlinecss}} work in it. These variables are set
(MageMe\WebForms\Model\Notification\Render\BodyWrapper):
| Variable | Value |
|---|---|
body_slot | Where the message goes. Required, exactly once |
preheader | The notification's Preheader, as plain text |
form_name | The form's name |
has_logo, logo_height | Whether the store set an email logo of its own, and its height (28 when none is set) |
email_direction, email_lang | ltr or rtl, and the store view's language, such as ar-SA |
email_align, email_align_opposite | left and right, swapped on a right-to-left store view |
Magento's own email variables, such as store.frontend_name, logo_url, logo_alt and template_styles, work
as in any Magento email template.
Override the other templates
The same way: copy the file into <your theme>/MageMe_WebForms/email/ with the same relative path. The
Store Template frame takes the variables of the table above; its styles come from
{{inlinecss file="MageMe_WebForms::css/email.css"}}, built from the module's view/base/web/css/email.less. The
inbound mailbox templates get nonce (the test message) and mail_subject, explanation and link_url (the
notice about an unmatched reply).
Use the store's email header and footer
Helpdesk Style has no logo and no footer. To send a notification inside your store's own Magento email header and footer, write it in Advanced Content. That body runs through Magento's email filter, so it can include the header and footer templates chosen for the store view in Content → Design → Configuration, under Transactional Emails.
-
Open the notification. In the Message section, in Content Source, select Advanced Content. Only admins whose role includes Write Advanced Notification Content see it.
-
Start the body with the header and end it with the footer, as Magento's own email templates do:
{{template config_path="design/email/header_template"}}<table><tr class="email-intro"><td><p>{{trans "Thank you. We received your request."}}</p></td></tr></table>{{template config_path="design/email/footer_template"}} -
Click Save. In the Preview, enter a submission or click Load Latest: the header and footer show there. Send Test Email then sends the email of that submission.
The header and footer follow the store view of the submission and are read when the email is built: a change to
the header template shows in the next email. They get Magento's usual email variables, such as logo_url and
template_styles. An email in Advanced Content has no plain-text copy.
Content from WebForms 3
When a store upgrades, each notification that pointed at a Magento email template gets its text moved inside the
notification, per store view (MageMe\WebForms\Model\Notification\Legacy\Embed\EmbedPlanner). WebForms' own
template, untouched, becomes Standard Content. A copy saved in Email Templates or a theme override becomes
Advanced Content with the template's exact text, so the customisation is kept. From then on, edit the text in
the notification, not in the template file.
Advanced Content runs through Magento's own filter, so {{template config_path="design/email/header_template"}}
and the other directives of a Magento email template still work there. See
Writing email content.
What you should see
The next email in Helpdesk Style uses your copy of the frame. Notifications in Advanced Content and notifications without a design are not affected.
An unchanged frame looks like this in a mail client: a white page with the store name in bold on top, then the message, at most 640 pixels wide.
Limits
- The frame must keep the message's place. If
{{var body_slot}}is missing, appears twice or the template fails to render, the email still goes out with the message alone, andvar/log/system.loggets a warning that names the reason, for example:WebForms email design "thread" was not applied for store 1: the wrapper kept no place for the message. The mail goes out unbranded.A notification whose revision still points at a WebForms 3 template (content_modelegacy_templateorlegacy_default) isn't sent at all: this version renders no Magento email template for a notification. - Which notifications get a frame. The admin editor saves Standard Content with Helpdesk Style
(
MageMe\WebForms\Model\Notification\DesignByMode). A notification written through the API carries the design named in itswrapper_ref:thread,store, or none. A notification created through the API without thewrapper_refkey gets the same design as one created in the admin;"wrapper_ref": nullkeeps it without a frame. Settingwrapper_refneeds Edit and Publish Forms (forms_edit), like every other notification command. See REST: Notifications. - Nested conditions. Magento's filter pairs a nested
{{if}}with the wrong closing tag. Keep conditions in a frame one level deep. - One frame per store view. The theme decides; there is no per-form frame.
Troubleshooting
- The email arrives without the frame. Look in
var/log/system.logfor the "email design … was not applied" line. It names the reason. - Your edits don't show. Check that the theme is assigned to the store view the submission came from, that
the file path ends in
MageMe_WebForms/email/wrapper/thread.html, and clean the cache. - A copy in Email Templates has no effect. That is expected; use the theme file.
What's next
- Writing email content: the message itself, Standard and Advanced Content.
- Theme and template overrides: the same fallback for storefront templates.
- REST: Notifications: notification documents, including
wrapper_ref.