How to add custom block

In this article we will add an additional block which name will be "custom".

1.1. Create a thumbnail of the block.

The image for a thumbnail of the new block you can download here.custom Copy the image to this directory:
app/code/Magetrend/Email/view/adminhtml/web/images/theme/default/custom.png

1.2. Create the block template (.phtml) file

Create new file called custom.phtml here:
app/code/Magetrend/Email/view/frontend/templates/email/default/block/custom.phtml
The content of file custom.phtml you can download here. Copy it to the file.

1.3. Create block layout file

Create new file called mtemail_custom.xml here:
app/code/Magetrend/Email/view/frontend/layout/mtemail_custom.xml
File content:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Custom Block" design_abstraction="custom">
    <body>
        <block class="Magetrend\Email\Block\Email\Block" name="block" template="Magetrend_Email::email/default/block.phtml">
            <block class="Magetrend\Email\Block\Email\Block\Template" name="block.content" template="Magetrend_Email::email/default/block/custom.phtml"/>
        </block>
    </body>
</page>

1.4. Add this block to the email template

Here for example will be used New Order email template. We will add the block to this template. Open the file:
app/code/Magetrend/Email/view/frontend/email/default/sales/order_new.html
After the line:
"layout handle=\"mtemail_footer\" area=\"frontend\" theme=\"default\" template_id=$this.id block_id=0 block_name=\"mtemail_footer\" noborder=\"1\" ":"mtemail_footer",
insert new block code:
"layout handle=\"mtemail_custom\" area=\"frontend\" theme=\"default\" template_id=$this.id block_id=0 block_name=\"mtemail_custom\" noborder=\"1\" ":"mtemail_custom",
Clear the cache by running command via ssh: php -f bin/magento cache:flush