Magento 2 Send Email Programmatically

Magento 2 send email programmatically – In this post, let’s find out how to send email programmatically in Magento 2. It will be useful for you in your custom module or new feature. What we need to do:

  • Create your email template in a html file.
  • Declare your email template.
  • Create a function to send your email.

We’re doing step by step:

Create new html file


with simple content:

Declare your email template, create xml file


with content:

Finally, create a function to send your email.

In this tutorial, we’re using a controller action. Create file:


with content:

You also can create this function in helper, model …

If you have any question, just leave a comment or contact us.