{"id":40284,"date":"2016-01-29T08:43:20","date_gmt":"2016-01-29T08:43:20","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=40284"},"modified":"2026-01-06T14:11:51","modified_gmt":"2026-01-06T14:11:51","slug":"magento-2-send-transactional-email-programmatically-in-your-custom-module","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/","title":{"rendered":"Magento 2- Send transactional email programmatically in your custom module"},"content":{"rendered":"\n<p>Here we learn how to send transactional emails programmatically in Magento 2 custom module.<\/p>\n\n\n\n<p>Transactional emails in Magento 2 play a crucial role in keeping customers informed about important events and actions on the store.<\/p>\n\n\n\n<p>Magento 2 provides a flexible and scalable email system that allows store owners and developers to manage transactional emails using predefined templates, custom email variables, and dynamic content.<\/p>\n\n\n\n<p><strong>1# First, we create a field in the configuration from where we can select which email template will use.<\/strong><\/p>\n\n\n\n<p>You can create a configuration field according to your section and group in app\/code\/NameSpace\/ModuleName\/etc\/adminhtml\/system.xml file as follows<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;field id=&quot;your_email_template_field_id&quot; translate=&quot;label comment&quot; type=&quot;select&quot; sortOrder=&quot;2&quot; showInDefault=&quot;1&quot; showInWebsite=&quot;1&quot; showInStore=&quot;1&quot;&gt;\n    &lt;label&gt;Label Of Your Field&lt;\/label&gt;\n    &lt;source_model&gt;Magento\\Config\\Model\\Config\\Source\\Email\\Template&lt;\/source_model&gt;\n    &lt;!-- This model return all transactional email template list of magento --&gt;\n&lt;\/field&gt;<\/pre>\n\n\n\n<p><strong>2# Now create an email template configuration file at app\/code\/NameSpace\/ModuleName\/etc location file name should be email_templates.xml<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Email:etc\/email_templates.xsd&quot;&gt;\n    &lt;template id=&quot;section_group_your_email_template_field_id&quot; label=&quot;Label Of Your Template File&quot; file=&quot;your_email_template.html&quot; type=&quot;html&quot; module=&quot;NameSpace_ModuleName&quot; area=&quot;adminhtml&quot;\/&gt;\n&lt;\/config&gt;\n&lt;!-- here you define your email template and its template location path--&gt;<\/pre>\n\n\n\n<p><strong>3# Now create an email template file at app\/code\/NameSpace\/ModuleName\/view\/adminhtml\/email with<\/strong> <strong>the same name you gave in email_template.xml file .<\/strong><\/p>\n\n\n\n<p><strong>Here we will use\u00a0 &#8220;your_email_template.html&#8221; for the<\/strong> <strong>email template<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;!--@subject Subject Of your email  @--&gt;\n&lt;!--@vars {\n&quot;var this.getUrl($store, &#039;admin&#039;)&quot;:&quot;Warehouse Account URL&quot;,\n&quot;var customer.email&quot;:&quot;Customer Email&quot;,\n&quot;var customer.name&quot;:&quot;Customer Name&quot;\n} @--&gt;\n\n{{template config_path=&quot;design\/email\/header_template&quot;}} &lt;!-- pathe of template header--&gt;\n\n&lt;!-- here $myvar1 , $myvar2, $myvar3, $myvar4, $myvar5, $myvar6 are variables in which we\n                                     asssign values when we use this template for send mail--&gt;\n\n&lt;!-- you can Modify content of template according to your requirement--&gt;\n&lt;table&gt;\n    &lt;tr class=&quot;email-intro&quot;&gt;\n        &lt;td&gt;\n            &lt;p class=&quot;greeting&quot;&gt;{{trans &quot;%customer_name,&quot; customer_name=$myvar3}}&lt;\/p&gt;\n            &lt;p&gt;\n                {{trans &quot;Your custom message.&quot;}}\n                {{trans &#039;Your custom message &lt;a href=&quot;%account_url&quot;&gt;logging into your account&lt;\/a&gt;.&#039; account_url=$this.getUrl($store,&#039;admin&#039;,&#091;_nosid:1]) |raw}}\n            &lt;\/p&gt;\n        &lt;\/td&gt;\n    &lt;\/tr&gt;\n    &lt;tr class=&quot;email-summary&quot;&gt;\n        &lt;td&gt;\n            &lt;h1&gt;{{trans &#039;Your Order &lt;span class=&quot;no-link&quot;&gt;#%increment_id&lt;\/span&gt;&#039; increment_id=$myvar1 |raw}}&lt;\/h1&gt;\n            &lt;p&gt;{{trans &#039;Placed on &lt;span class=&quot;no-link&quot;&gt;%created_at&lt;\/span&gt;&#039; created_at=$myvar2 |raw}}&lt;\/p&gt;\n        &lt;\/td&gt;\n    &lt;\/tr&gt;\n    &lt;tr class=&quot;email-information&quot;&gt;\n        &lt;td&gt;\n            &lt;table class=&quot;order-details&quot;&gt;\n                &lt;tr&gt;\n                    &lt;td class=&quot;address-details&quot;&gt;\n                        &lt;h3&gt;{{trans &quot;Billing Info&quot;}}&lt;\/h3&gt;\n                        &lt;p&gt;{{var myvar4|raw}}&lt;\/p&gt;\n                    &lt;\/td&gt;\n                &lt;\/tr&gt;\n            &lt;\/table&gt;\n            &lt;table class=&quot;email-items&quot;&gt;\n                &lt;thead&gt;\n                    &lt;tr&gt;\n                        &lt;th class=&quot;item-info&quot;&gt;{{trans &quot;Item&quot;}}&lt;\/th&gt;\n                        &lt;th class=&quot;item-info&quot;&gt;{{trans &quot;Sku&quot;}}&lt;\/th&gt;\n                    &lt;\/tr&gt;\n                &lt;\/thead&gt;\n                &lt;tbody&gt;\n                    {{var myvar8|raw}}\n                &lt;\/tbody&gt;\n            &lt;\/table&gt;\n        &lt;\/td&gt;\n    &lt;\/tr&gt;\n&lt;\/table&gt;\n\n{{template config_path=&quot;design\/email\/footer_template&quot;}} &lt;!--footer of template--&gt;<\/pre>\n\n\n\n<p><strong>4# Now the template is ready, and we will write code to send mail.<\/strong><br>Write the send mail code in the action from where you want to send this mail.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/* Here we prepare data for our email  *\/\n\n\n\/* Receiver Detail  *\/\n$receiverInfo = &#091;\n    &#039;name&#039; =&gt; &#039;Reciver Name&#039;,\n    &#039;email&#039; =&gt; &#039;receiver@address.com&#039;\n];\n\n\n\/* Sender Detail  *\/\n$senderInfo = &#091;\n    &#039;name&#039; =&gt; &#039;Sender Name&#039;,\n    &#039;email&#039; =&gt; &#039;sender@addess.com&#039;,\n];\n\n\n\/* Assign values for your template variables  *\/\n$emailTemplateVariables = array();\n$emailTempVariables&#091;&#039;myvar1&#039;] = $variablevalue1;\n$emailTempVariables&#091;&#039;myvar2&#039;] = $variablevalue2;\n                 ...\n                 ...\n                 ...    \n\n\/* We write send mail function in helper because if we want to \n   use same in other action then we can call it directly from helper *\/  \n\n\/* call send mail method from helper or where you define it*\/  \n$this-&gt;_objectManager-&gt;get(&#039;NameSpace\\ModuleName\\Helper\\Email&#039;)-&gt;yourCustomMailSendMethod(\n      $emailTempVariables,\n      $senderInfo,\n      $receiverInfo\n  );<\/pre>\n\n\n\n<p>5# Helper file where we define our custom send mail function<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace NameSpace\\ModuleName\\Helper;\n\n\/**\n * Custom Module Email helper\n *\/\nclass Email extends \\Magento\\Framework\\App\\Helper\\AbstractHelper\n{\n    const XML_PATH_EMAIL_TEMPLATE_FIELD  = &#039;section\/group\/your_email_template_field_id&#039;;\n    \/* Here section and group refer to name of section and group where you create this field in configuration*\/\n\n    \/**\n     * @var \\Magento\\Framework\\App\\Config\\ScopeConfigInterface\n     *\/\n    protected $_scopeConfig;\n\n    \/**\n     * Store manager\n     *\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     *\/\n    protected $_storeManager;\n\n    \/**\n     * @var \\Magento\\Framework\\Translate\\Inline\\StateInterface\n     *\/\n    protected $inlineTranslation;\n\n    \/**\n     * @var \\Magento\\Framework\\Mail\\Template\\TransportBuilder\n     *\/\n    protected $_transportBuilder;\n    \n    \/**\n     * @var string\n    *\/\n    protected $temp_id;\n\n    \/**\n    * @param Magento\\Framework\\App\\Helper\\Context $context\n    * @param Magento\\Framework\\App\\Config\\ScopeConfigInterface $scopeConfig\n    * @param Magento\\Store\\Model\\StoreManagerInterface $storeManager\n    * @param Magento\\Framework\\Translate\\Inline\\StateInterface $inlineTranslation\n    * @param Magento\\Framework\\Mail\\Template\\TransportBuilder $transportBuilder\n    *\/\n    public function __construct(\n        \\Magento\\Framework\\App\\Helper\\Context $context,\n        \\Magento\\Store\\Model\\StoreManagerInterface $storeManager,\n        \\Magento\\Framework\\Translate\\Inline\\StateInterface $inlineTranslation,\n        \\Magento\\Framework\\Mail\\Template\\TransportBuilder $transportBuilder\n    ) {\n        $this-&gt;_scopeConfig = $context;\n        parent::__construct($context);\n        $this-&gt;_storeManager = $storeManager;\n        $this-&gt;inlineTranslation = $inlineTranslation;\n        $this-&gt;_transportBuilder = $transportBuilder; \n    }\n\n    \/**\n     * Return store configuration value of your template field that which id you set for template\n     *\n     * @param string $path\n     * @param int $storeId\n     * @return mixed\n     *\/\n    protected function getConfigValue($path, $storeId)\n    {\n        return $this-&gt;scopeConfig-&gt;getValue(\n            $path,\n            \\Magento\\Store\\Model\\ScopeInterface::SCOPE_STORE,\n            $storeId\n        );\n    }\n\n    \/**\n     * Return store \n     *\n     * @return Store\n     *\/\n    public function getStore()\n    {\n        return $this-&gt;_storeManager-&gt;getStore();\n    }\n\n    \/**\n     * Return template id according to store\n     *\n     * @return mixed\n     *\/\n    public function getTemplateId($xmlPath)\n    {\n        return $this-&gt;getConfigValue($xmlPath, $this-&gt;getStore()-&gt;getStoreId());\n    }\n\n    \/**\n     * &#091;generateTemplate description]  with template file and tempaltes variables values                \n     * @param  Mixed $emailTemplateVariables \n     * @param  Mixed $senderInfo             \n     * @param  Mixed $receiverInfo           \n     * @return void\n     *\/\n    public function generateTemplate($emailTemplateVariables,$senderInfo,$receiverInfo)\n    {\n        $template =  $this-&gt;_transportBuilder-&gt;setTemplateIdentifier($this-&gt;temp_id)\n                -&gt;setTemplateOptions(\n                    &#091;\n                        &#039;area&#039; =&gt; \\Magento\\Framework\\App\\Area::AREA_FRONTEND, \/* here you can defile area and\n                                                                                 store of template for which you prepare it *\/\n                        &#039;store&#039; =&gt; $this-&gt;_storeManager-&gt;getStore()-&gt;getId(),\n                    ]\n                )\n                -&gt;setTemplateVars($emailTemplateVariables)\n                -&gt;setFrom($senderInfo)\n                -&gt;addTo($receiverInfo&#091;&#039;email&#039;],$receiverInfo&#091;&#039;name&#039;]);\n        return $this;        \n    }\n\n    \/**\n     * &#091;sendInvoicedOrderEmail description]                  \n     * @param  Mixed $emailTemplateVariables \n     * @param  Mixed $senderInfo             \n     * @param  Mixed $receiverInfo           \n     * @return void\n     *\/\n    \/* your send mail method*\/\n    public function yourCustomMailSendMethod($emailTemplateVariables,$senderInfo,$receiverInfo)\n    {\n\n        $this-&gt;temp_id = $this-&gt;getTemplateId(self::XML_PATH_EMAIL_TEMPLATE_FIELD);\n        $this-&gt;inlineTranslation-&gt;suspend();    \n        $this-&gt;generateTemplate($emailTemplateVariables,$senderInfo,$receiverInfo);    \n        $transport = $this-&gt;_transportBuilder-&gt;getTransport();\n        $transport-&gt;sendMessage();        \n        $this-&gt;inlineTranslation-&gt;resume();\n    }\n\n}<\/pre>\n\n\n\n<p>With this, you have successfully learn to send transactional emails programmatically in Magento 2.<\/p>\n\n\n\n<p>For technical assistance, please get in touch with us via email at\u00a0<a href=\"mailto:support@webkul.com\" target=\"_blank\" rel=\"noreferrer noopener\">support@webkul.com<\/a>.<\/p>\n\n\n\n<p>Discover powerful solutions to enhance your Magento 2 store by exploring our\u00a0<a href=\"https:\/\/store.webkul.com\/Magento-2.html\">Magento 2 plugins<\/a>\u00a0page.<\/p>\n\n\n\n<p>Bring your vision to life with custom-built solutions\u2014hire skilled\u00a0<a href=\"https:\/\/webkul.com\/hire-magento-developers\/\">Magento 2 developers<\/a>\u00a0today.<\/p>\n\n\n\n<p>Thanks \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here we learn how to send transactional emails programmatically in Magento 2 custom module. Transactional emails in Magento 2 play a crucial role in keeping customers informed about important events and actions on the store. Magento 2 provides a flexible and scalable email system that allows store owners and developers to manage transactional emails using <a href=\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":4,"featured_media":39718,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,302,13],"tags":[1347,2056,2070,775],"class_list":["post-40284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento","category-magento2","category-php","tag-email","tag-magento","tag-magento2","tag-template"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Send Transactional Emails Programmatically in Magento 2<\/title>\n<meta name=\"description\" content=\"Learn how to send transactional emails programmatically in Magento 2 custom modules, including email templates, variables, and code examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Send Transactional Emails Programmatically in Magento 2\" \/>\n<meta property=\"og:description\" content=\"Learn how to send transactional emails programmatically in Magento 2 custom modules, including email templates, variables, and code examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-29T08:43:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-06T14:11:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abhishek Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/\"},\"author\":{\"name\":\"Abhishek Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0\"},\"headline\":\"Magento 2- Send transactional email programmatically in your custom module\",\"datePublished\":\"2016-01-29T08:43:20+00:00\",\"dateModified\":\"2026-01-06T14:11:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/\"},\"wordCount\":265,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png\",\"keywords\":[\"Email\",\"magento\",\"Magento2\",\"template\"],\"articleSection\":[\"magento\",\"Magento2\",\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/\",\"url\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/\",\"name\":\"Send Transactional Emails Programmatically in Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png\",\"datePublished\":\"2016-01-29T08:43:20+00:00\",\"dateModified\":\"2026-01-06T14:11:51+00:00\",\"description\":\"Learn how to send transactional emails programmatically in Magento 2 custom modules, including email templates, variables, and code examples.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento 2- Send transactional email programmatically in your custom module\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0\",\"name\":\"Abhishek Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Abhishek Singh\"},\"description\":\"Adobe Commerce certified Magento developer with over 12 years of experience at Webkul. Passionate about scalable Magento 2-based webshops, AI, and multi-channel integrations, Abhishek consistently delivers innovative and efficient e-commerce solutions that propel businesses forward.\",\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/abhishek\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Send Transactional Emails Programmatically in Magento 2","description":"Learn how to send transactional emails programmatically in Magento 2 custom modules, including email templates, variables, and code examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/","og_locale":"en_US","og_type":"article","og_title":"Send Transactional Emails Programmatically in Magento 2","og_description":"Learn how to send transactional emails programmatically in Magento 2 custom modules, including email templates, variables, and code examples.","og_url":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-01-29T08:43:20+00:00","article_modified_time":"2026-01-06T14:11:51+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png","type":"image\/png"}],"author":"Abhishek Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Abhishek Singh","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/"},"author":{"name":"Abhishek Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0"},"headline":"Magento 2- Send transactional email programmatically in your custom module","datePublished":"2016-01-29T08:43:20+00:00","dateModified":"2026-01-06T14:11:51+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/"},"wordCount":265,"commentCount":5,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png","keywords":["Email","magento","Magento2","template"],"articleSection":["magento","Magento2","php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/","url":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/","name":"Send Transactional Emails Programmatically in Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png","datePublished":"2016-01-29T08:43:20+00:00","dateModified":"2026-01-06T14:11:51+00:00","description":"Learn how to send transactional emails programmatically in Magento 2 custom modules, including email templates, variables, and code examples.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/01\/Magneto-Code-Snippet-5.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/magento-2-send-transactional-email-programmatically-in-your-custom-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento 2- Send transactional email programmatically in your custom module"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0","name":"Abhishek Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Abhishek Singh"},"description":"Adobe Commerce certified Magento developer with over 12 years of experience at Webkul. Passionate about scalable Magento 2-based webshops, AI, and multi-channel integrations, Abhishek consistently delivers innovative and efficient e-commerce solutions that propel businesses forward.","sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/abhishek\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/40284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=40284"}],"version-history":[{"count":14,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/40284\/revisions"}],"predecessor-version":[{"id":520818,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/40284\/revisions\/520818"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/39718"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=40284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=40284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=40284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}