Magento store emails and a branded email template
Every email Magento 2.4.9 sends to your customers has an on/off switch, a sender and a template. Here is where each one is set: order, invoice, shipment and credit memo, the welcome email and the newsletter emails. Then we copy Magento’s New Order template, give it our own header and footer, use it for customers and guests, and test every email end to end.
Downloads
The branded New Order template from the video. Paste the content into Template Content and the subject into Template Subject. The store name, address, email and phone come from your own configuration, so nothing in the file needs editing; change the two colours (#160040 and #79018C) to your brand’s.
Which emails, where
| Where it is set | |
|---|---|
| Order, invoice, shipment, credit memo (and their comment updates) | Stores › Configuration › Sales › Sales Emails |
| Welcome email, account confirmation | Stores › Configuration › Customers › Customer Configuration › Create New Account Options |
| Newsletter confirmation, success, unsubscribe | Stores › Configuration › Customers › Newsletter › Subscription Options |
| Your own designs | Marketing › Communications › Email Templates |
The sender identities (General Contact, Sales Representative, Customer Support…) are set in Store Email Addresses, see Lesson 4. The emails go out through SMTP, see Lesson 6.
Sales emails
Stores › Configuration › Sales › Sales Emails. Each group (Order, Order Comments, Invoice, Invoice Comments, Shipment, Shipment Comments, Credit Memo, Credit Memo Comments) has the same fields:
| Field | What it does | In the video |
|---|---|---|
| General Settings › Asynchronous sending | Sends the emails in the background with cron, so the checkout does not wait for the mail server. Needs a working Magento cron. | Disable (default) |
| Enabled | Switches this email on or off. | Yes |
| New Order Confirmation Email Sender | The sender identity. | Sales Representative |
| New Order Confirmation Template | The template for registered customers. | MageBooster New Order (after the change) |
| New Order Confirmation Template for Guest | The template for guest checkouts. | MageBooster New Order (after the change) |
| Send Order Email Copy To | One or more of your own addresses, comma separated. | empty |
| Send Order Email Copy Method | Bcc: the customer does not see the copy addresses. Separate Email: a separate email to each address. | Bcc |
Welcome and newsletter emails
| Setting | Where | In the video |
|---|---|---|
| Default Welcome Email | Customer Configuration › Create New Account Options | New Account (Default) |
| Email Sender | Customer Configuration › Create New Account Options | Customer Support |
| Require Emails Confirmation | Customer Configuration › Create New Account Options | No: Yes sends a confirmation link first, and the welcome email after the click |
| Need to Confirm | Newsletter › Subscription Options | No: the subscriber gets the success email at once |
| Confirmation / Success / Unsubscription Email Sender and Template | Newsletter › Subscription Options | General Contact, default templates |
A branded template
- Marketing › Email Templates › Add New Template.
- Under Load Default Template, pick New Order (Magento_Sales) and click Load Template. Magento copies its own subject and content into the form, so you start from an email that already works.
- Replace Template Content with the downloaded
mb-new-order.html(or edit Magento’s version yourself). - Template Name:
MageBooster New Order(any name; it shows in the template dropdowns). Save Template.
What the branded version changes, compared with Magento’s default: the line {{template config_path="design/email/header_template"}} is replaced by our own dark purple header with the store name, and {{template config_path="design/email/footer_template"}} by a footer with the store’s name, address, email and phone. The first line, {{inlinecss file="css/email-inline.css"}}, keeps the theme’s email styles for the order details and the items table. Everything in between is Magento’s own content.
{{inlinecss file="css/email-inline.css"}}
<div style="max-width:640px;margin:0 auto;font-family:Arial,Helvetica,sans-serif;color:#333">
<table width="100%" cellpadding="0" cellspacing="0" style="background:#160040;border-radius:12px 12px 0 0">
<tr>
<td style="padding:26px 30px;font-family:Arial,sans-serif">
<span style="display:inline-block;background:#79018C;color:#fff;font-weight:bold;font-size:13px;letter-spacing:1px;padding:4px 10px;border-radius:6px">ORDER CONFIRMATION</span>
<div style="color:#fff;font-size:26px;font-weight:bold;margin-top:12px">{{var store.frontend_name}}</div>
</td>
</tr>
</table>
<div style="height:4px;background:#79018C"></div>
<div style="background:#fff;padding:8px 30px 0">
<table>
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%customer_name," customer_name=$order_data.customer_name}}</p>
<p>
{{trans "Thank you for your order from %store_name." store_name=$store.frontend_name}}
{{trans "Once your package ships we will send you a tracking number."}}
{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}
</p>
<p>
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
{{depend store_hours}}
{{trans 'Our hours are <span class="no-link">%store_hours</span>.' store_hours=$store_hours |raw}}
{{/depend}}
</p>
</td>
</tr>
<tr class="email-summary">
<td>
<h1 style="color:#160040">{{trans 'Your Order <span class="no-link">#%increment_id</span>' increment_id=$order.increment_id |raw}}</h1>
<p>{{trans 'Placed on <span class="no-link">%created_at</span>' created_at=$created_at_formatted |raw}}</p>
</td>
</tr>
<tr class="email-information">
<td>
{{depend order_data.email_customer_note}}
<table class="message-info">
<tr>
<td>
{{var order_data.email_customer_note|escape|nl2br}}
</td>
</tr>
</table>
{{/depend}}
<table class="order-details">
<tr>
<td class="address-details">
<h3>{{trans "Billing Info"}}</h3>
<p>{{var formattedBillingAddress|raw}}</p>
</td>
{{depend order_data.is_not_virtual}}
<td class="address-details">
<h3>{{trans "Shipping Info"}}</h3>
<p>{{var formattedShippingAddress|raw}}</p>
</td>
{{/depend}}
</tr>
<tr>
<td class="method-info">
<h3>{{trans "Payment Method"}}</h3>
{{var payment_html|raw}}
</td>
{{depend order_data.is_not_virtual}}
<td class="method-info">
<h3>{{trans "Shipping Method"}}</h3>
<p>{{var order.shipping_description}}</p>
{{if shipping_msg}}
<p>{{var shipping_msg}}</p>
{{/if}}
</td>
{{/depend}}
</tr>
</table>
{{layout handle="sales_email_order_items" order_id=$order_id area="frontend"}}<br>
</td>
</tr>
</table>
</div>
<table width="100%" cellpadding="0" cellspacing="0" style="background:#f4eff9;border-radius:0 0 12px 12px">
<tr>
<td style="padding:22px 30px;font-family:Arial,sans-serif;font-size:13px;color:#4a4060;line-height:1.6">
<strong style="color:#160040">{{config path="general/store_information/name"}}</strong><br>
{{config path="general/store_information/street_line1"}}, {{config path="general/store_information/city"}} {{config path="general/store_information/postcode"}}<br>
{{var store_email}}{{depend store_phone}} · {{var store_phone}}{{/depend}}<br>
<span style="color:#79018C">Thank you for shopping with us.</span>
</td>
</tr>
</table>
</div>
Template variables
Variables sit in double curly braces. Insert Variable in the template form lists every variable this email can use. A few from the New Order template:
| Variable | Shows |
|---|---|
{{var order.increment_id}} / $order.increment_id | The order number |
{{var order_data.customer_name}} | The customer name |
{{var formattedBillingAddress|raw}} | The billing address |
{{var payment_html|raw}} | The payment method |
{{var store.frontend_name}} | The store name |
{{config path="general/store_information/phone"}} | Any configuration value, here the store phone |
{{depend store_phone}}…{{/depend}} | Shows the part only when the value is set |
{{layout handle="sales_email_order_items" …}} | The items table and totals |
Using the template
Stores › Configuration › Sales › Sales Emails › Order: untick Use system value next to New Order Confirmation Template and pick MageBooster New Order. Do the same for New Order Confirmation Template for Guest. Save Config.
See what is set:
cd /var/www/magento # which email settings differ from Magento's defaults sudo -u magento bin/magento config:show | grep -E '^(sales_email|customer/create_account|newsletter/subscription)/' # your own templates and their IDs (the value Sales Emails stores) sudo mariadb magento -e "select template_id, template_code, orig_template_code from email_template"
Testing every email
On a test server (in the video, Mailpit catches every email):
- On the storefront, create a customer account with Sign Up for Newsletter ticked: the welcome email (from Customer Support) and the newsletter success email (from General Contact).
- Place an order: the order confirmation (from Sales Representative) with the branded template.
- In Sales › Orders, open the order, click Invoice, keep Email Copy of Invoice ticked and Submit Invoice: the invoice email.
- Click Credit Memo, keep Email Copy of Credit Memo ticked and click Refund Offline (a bank transfer order is refunded offline; you send the money back yourself): the credit memo email.
The invoice and credit memo still use Magento’s default design. Make branded copies of New Invoice and New Credit Memo (and their Guest versions) the same way, so every email looks the same.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| No email at all | Check Enabled in the group, then the SMTP settings from Lesson 6. With Asynchronous sending on, the email waits for the Magento cron. |
| The new template does not show in the dropdown | The dropdown only lists templates that are based on that email: load the right default (New Order for the order email) before saving. |
| Variables show as text, or are empty | Use the variable names from Insert Variable for this email; some templates use $order.increment_id, not order.increment_id. |
| The email looks unstyled (serif font) | Keep {{inlinecss file="css/email-inline.css"}} at the top when you replace the header template. |
| Copy To addresses get nothing | Check the comma separated list, and the Copy Method (Bcc or Separate Email). |
Next lesson
Lesson 8: the Magento REST API: how to set up an integration, and which bearer token to use.
▶ Watch every MageBooster lesson on YouTube: all lessons in order · subscribe to the channel

