Email template 'custom_template' is not defined in magento2












-1















hello everyone i am getting error when sending mail to admin
email_templates.xml



<?xml version="1.0"?>                                                  
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:
etc/email_templates.xsd">
<template id="customemail_email_template" label="Custom Email Template"
file="custom_template.html" type="html"
module="Magneto_WholesaleApplication" area="frontend" />
</config>


custom_template.html



<!--@subject Sending email from my custom module @-->

{{template config_path="design/email/header_template"}}
<table>
<tr class="email-intro">
<td>
Email: {{var email}}
</td>
<td>
Name: {{var name}}
</td>
<td>
cname: {{var cname}}
</td>
<td>
address: {{var address}}
</td>
<td>
address2: {{var address2}}
</td>
<td>
city: {{var city}}
</td>
<td>
state: {{var state}}
</td>
<td>
zipcode: {{var zipcode}}
</td>
<td>
country_id: {{var country_id}}
</td>
<td>
areacode: {{var areacode}}
</td>
<td>
phonenumber: {{var phonenumber}}
</td>
<td>
website: {{var website}}
</td>
<td>
reseller: {{var reseller}}
</td>
<td>
description: {{var description}}
</td>
<td>
additional: {{var additional}}
</td>
<td>
image: {{var image}}
</td>
</tr>
</table>

{{template config_path="design/email/footer_template"}}


Post.php



<?php
namespace MagnetoWholesaleApplicationControllerIndex;

use ZendLogFilterTimestamp;

class Post extends MagentoFrameworkAppActionAction
{
const XML_PATH_EMAIL_RECIPIENT_NAME =
'trans_email/ident_support/name';
const XML_PATH_EMAIL_RECIPIENT_EMAIL =
'trans_email/ident_support/email';

protected $_inlineTranslation;
protected $_transportBuilder;
protected $_scopeConfig;
protected $_logLoggerInterface;

public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkTranslateInlineStateInterface $inlineTranslation,
MagentoFrameworkMailTemplateTransportBuilder $transportBuilder,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
PsrLogLoggerInterface $loggerInterface,
array $data =

)
{
$this->_inlineTranslation = $inlineTranslation;
$this->_transportBuilder = $transportBuilder;
$this->_scopeConfig = $scopeConfig;
$this->_logLoggerInterface = $loggerInterface;
$this->messageManager = $context->getMessageManager();


parent::__construct($context);


}

public function execute()
{
$post = $this->getRequest()->getPost();
try
{
// Send Mail
$this->_inlineTranslation->suspend();
$storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;

$sender = [
'name' => $post['name'],
'cname' => $post['cname'],
'email' => $post['email'],
'address' => $post['address'],
'address2' => $post['address2'],
'city' => $post['city'],
'state' => $post['state'],
'zipcode' => $post['zipcode'],
'country_id' => $post['country_id'],
'areacode' => $post['areacode'],
'phonenumber' => $post['phonenumber'],
'website' => $post['website'],
'reseller' => $post['reseller'],
'description' => $post['description'],
'additional' => $post['additional'],
'image' => $post['image']

];

$sentToEmail = $this->_scopeConfig -
>getValue('trans_email/ident_general/email',MagentoStoreModel
ScopeInterface::SCOPE_STORE);

$sentToName = $this->_scopeConfig -

>getValue('trans_email/ident_general/name',MagentoStoreModel
ScopeInterface::SCOPE_STORE);


$transport = $this->_transportBuilder
->setTemplateIdentifier('custom_template')
->setTemplateOptions(
[
'area' => 'frontend',
'store' => MagentoStoreModelStore::DEFAULT_STORE_ID,
]
)
->setTemplateVars([
'name' => $post['name'],
'cname' => $post['cname'],
'email' => $post['email'],
'address' => $post['address'],
'address2' => $post['address2'],
'city' => $post['city'],
'state' => $post['state'],
'zipcode' => $post['zipcode'],
'country_id' => $post['country_id'],
'areacode' => $post['areacode'],
'phonenumber' => $post['phonenumber'],
'website' => $post['website'],
'reseller' => $post['reseller'],
'description' => $post['description'],
'additional' => $post['additional'],
'image' => $post['image']
])
->setFrom($sender)
->addTo($sentToEmail,$sentToName)
//->addTo('owner@example.com','owner')
->getTransport();

$transport->sendMessage();

$this->_inlineTranslation->resume();
$this->messageManager->addSuccess('Email sent successfully');
$this->_redirect('');

} catch(Exception $e){
$this->messageManager->addError($e->getMessage());
$this->_logLoggerInterface->debug($e->getMessage());
exit;
}



}
}


when i am submiting value through submit button error is coming










share|improve this question



























    -1















    hello everyone i am getting error when sending mail to admin
    email_templates.xml



    <?xml version="1.0"?>                                                  
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-
    instance"xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:
    etc/email_templates.xsd">
    <template id="customemail_email_template" label="Custom Email Template"
    file="custom_template.html" type="html"
    module="Magneto_WholesaleApplication" area="frontend" />
    </config>


    custom_template.html



    <!--@subject Sending email from my custom module @-->

    {{template config_path="design/email/header_template"}}
    <table>
    <tr class="email-intro">
    <td>
    Email: {{var email}}
    </td>
    <td>
    Name: {{var name}}
    </td>
    <td>
    cname: {{var cname}}
    </td>
    <td>
    address: {{var address}}
    </td>
    <td>
    address2: {{var address2}}
    </td>
    <td>
    city: {{var city}}
    </td>
    <td>
    state: {{var state}}
    </td>
    <td>
    zipcode: {{var zipcode}}
    </td>
    <td>
    country_id: {{var country_id}}
    </td>
    <td>
    areacode: {{var areacode}}
    </td>
    <td>
    phonenumber: {{var phonenumber}}
    </td>
    <td>
    website: {{var website}}
    </td>
    <td>
    reseller: {{var reseller}}
    </td>
    <td>
    description: {{var description}}
    </td>
    <td>
    additional: {{var additional}}
    </td>
    <td>
    image: {{var image}}
    </td>
    </tr>
    </table>

    {{template config_path="design/email/footer_template"}}


    Post.php



    <?php
    namespace MagnetoWholesaleApplicationControllerIndex;

    use ZendLogFilterTimestamp;

    class Post extends MagentoFrameworkAppActionAction
    {
    const XML_PATH_EMAIL_RECIPIENT_NAME =
    'trans_email/ident_support/name';
    const XML_PATH_EMAIL_RECIPIENT_EMAIL =
    'trans_email/ident_support/email';

    protected $_inlineTranslation;
    protected $_transportBuilder;
    protected $_scopeConfig;
    protected $_logLoggerInterface;

    public function __construct(
    MagentoFrameworkAppActionContext $context,
    MagentoFrameworkTranslateInlineStateInterface $inlineTranslation,
    MagentoFrameworkMailTemplateTransportBuilder $transportBuilder,
    MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
    PsrLogLoggerInterface $loggerInterface,
    array $data =

    )
    {
    $this->_inlineTranslation = $inlineTranslation;
    $this->_transportBuilder = $transportBuilder;
    $this->_scopeConfig = $scopeConfig;
    $this->_logLoggerInterface = $loggerInterface;
    $this->messageManager = $context->getMessageManager();


    parent::__construct($context);


    }

    public function execute()
    {
    $post = $this->getRequest()->getPost();
    try
    {
    // Send Mail
    $this->_inlineTranslation->suspend();
    $storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;

    $sender = [
    'name' => $post['name'],
    'cname' => $post['cname'],
    'email' => $post['email'],
    'address' => $post['address'],
    'address2' => $post['address2'],
    'city' => $post['city'],
    'state' => $post['state'],
    'zipcode' => $post['zipcode'],
    'country_id' => $post['country_id'],
    'areacode' => $post['areacode'],
    'phonenumber' => $post['phonenumber'],
    'website' => $post['website'],
    'reseller' => $post['reseller'],
    'description' => $post['description'],
    'additional' => $post['additional'],
    'image' => $post['image']

    ];

    $sentToEmail = $this->_scopeConfig -
    >getValue('trans_email/ident_general/email',MagentoStoreModel
    ScopeInterface::SCOPE_STORE);

    $sentToName = $this->_scopeConfig -

    >getValue('trans_email/ident_general/name',MagentoStoreModel
    ScopeInterface::SCOPE_STORE);


    $transport = $this->_transportBuilder
    ->setTemplateIdentifier('custom_template')
    ->setTemplateOptions(
    [
    'area' => 'frontend',
    'store' => MagentoStoreModelStore::DEFAULT_STORE_ID,
    ]
    )
    ->setTemplateVars([
    'name' => $post['name'],
    'cname' => $post['cname'],
    'email' => $post['email'],
    'address' => $post['address'],
    'address2' => $post['address2'],
    'city' => $post['city'],
    'state' => $post['state'],
    'zipcode' => $post['zipcode'],
    'country_id' => $post['country_id'],
    'areacode' => $post['areacode'],
    'phonenumber' => $post['phonenumber'],
    'website' => $post['website'],
    'reseller' => $post['reseller'],
    'description' => $post['description'],
    'additional' => $post['additional'],
    'image' => $post['image']
    ])
    ->setFrom($sender)
    ->addTo($sentToEmail,$sentToName)
    //->addTo('owner@example.com','owner')
    ->getTransport();

    $transport->sendMessage();

    $this->_inlineTranslation->resume();
    $this->messageManager->addSuccess('Email sent successfully');
    $this->_redirect('');

    } catch(Exception $e){
    $this->messageManager->addError($e->getMessage());
    $this->_logLoggerInterface->debug($e->getMessage());
    exit;
    }



    }
    }


    when i am submiting value through submit button error is coming










    share|improve this question

























      -1












      -1








      -1








      hello everyone i am getting error when sending mail to admin
      email_templates.xml



      <?xml version="1.0"?>                                                  
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-
      instance"xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:
      etc/email_templates.xsd">
      <template id="customemail_email_template" label="Custom Email Template"
      file="custom_template.html" type="html"
      module="Magneto_WholesaleApplication" area="frontend" />
      </config>


      custom_template.html



      <!--@subject Sending email from my custom module @-->

      {{template config_path="design/email/header_template"}}
      <table>
      <tr class="email-intro">
      <td>
      Email: {{var email}}
      </td>
      <td>
      Name: {{var name}}
      </td>
      <td>
      cname: {{var cname}}
      </td>
      <td>
      address: {{var address}}
      </td>
      <td>
      address2: {{var address2}}
      </td>
      <td>
      city: {{var city}}
      </td>
      <td>
      state: {{var state}}
      </td>
      <td>
      zipcode: {{var zipcode}}
      </td>
      <td>
      country_id: {{var country_id}}
      </td>
      <td>
      areacode: {{var areacode}}
      </td>
      <td>
      phonenumber: {{var phonenumber}}
      </td>
      <td>
      website: {{var website}}
      </td>
      <td>
      reseller: {{var reseller}}
      </td>
      <td>
      description: {{var description}}
      </td>
      <td>
      additional: {{var additional}}
      </td>
      <td>
      image: {{var image}}
      </td>
      </tr>
      </table>

      {{template config_path="design/email/footer_template"}}


      Post.php



      <?php
      namespace MagnetoWholesaleApplicationControllerIndex;

      use ZendLogFilterTimestamp;

      class Post extends MagentoFrameworkAppActionAction
      {
      const XML_PATH_EMAIL_RECIPIENT_NAME =
      'trans_email/ident_support/name';
      const XML_PATH_EMAIL_RECIPIENT_EMAIL =
      'trans_email/ident_support/email';

      protected $_inlineTranslation;
      protected $_transportBuilder;
      protected $_scopeConfig;
      protected $_logLoggerInterface;

      public function __construct(
      MagentoFrameworkAppActionContext $context,
      MagentoFrameworkTranslateInlineStateInterface $inlineTranslation,
      MagentoFrameworkMailTemplateTransportBuilder $transportBuilder,
      MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
      PsrLogLoggerInterface $loggerInterface,
      array $data =

      )
      {
      $this->_inlineTranslation = $inlineTranslation;
      $this->_transportBuilder = $transportBuilder;
      $this->_scopeConfig = $scopeConfig;
      $this->_logLoggerInterface = $loggerInterface;
      $this->messageManager = $context->getMessageManager();


      parent::__construct($context);


      }

      public function execute()
      {
      $post = $this->getRequest()->getPost();
      try
      {
      // Send Mail
      $this->_inlineTranslation->suspend();
      $storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;

      $sender = [
      'name' => $post['name'],
      'cname' => $post['cname'],
      'email' => $post['email'],
      'address' => $post['address'],
      'address2' => $post['address2'],
      'city' => $post['city'],
      'state' => $post['state'],
      'zipcode' => $post['zipcode'],
      'country_id' => $post['country_id'],
      'areacode' => $post['areacode'],
      'phonenumber' => $post['phonenumber'],
      'website' => $post['website'],
      'reseller' => $post['reseller'],
      'description' => $post['description'],
      'additional' => $post['additional'],
      'image' => $post['image']

      ];

      $sentToEmail = $this->_scopeConfig -
      >getValue('trans_email/ident_general/email',MagentoStoreModel
      ScopeInterface::SCOPE_STORE);

      $sentToName = $this->_scopeConfig -

      >getValue('trans_email/ident_general/name',MagentoStoreModel
      ScopeInterface::SCOPE_STORE);


      $transport = $this->_transportBuilder
      ->setTemplateIdentifier('custom_template')
      ->setTemplateOptions(
      [
      'area' => 'frontend',
      'store' => MagentoStoreModelStore::DEFAULT_STORE_ID,
      ]
      )
      ->setTemplateVars([
      'name' => $post['name'],
      'cname' => $post['cname'],
      'email' => $post['email'],
      'address' => $post['address'],
      'address2' => $post['address2'],
      'city' => $post['city'],
      'state' => $post['state'],
      'zipcode' => $post['zipcode'],
      'country_id' => $post['country_id'],
      'areacode' => $post['areacode'],
      'phonenumber' => $post['phonenumber'],
      'website' => $post['website'],
      'reseller' => $post['reseller'],
      'description' => $post['description'],
      'additional' => $post['additional'],
      'image' => $post['image']
      ])
      ->setFrom($sender)
      ->addTo($sentToEmail,$sentToName)
      //->addTo('owner@example.com','owner')
      ->getTransport();

      $transport->sendMessage();

      $this->_inlineTranslation->resume();
      $this->messageManager->addSuccess('Email sent successfully');
      $this->_redirect('');

      } catch(Exception $e){
      $this->messageManager->addError($e->getMessage());
      $this->_logLoggerInterface->debug($e->getMessage());
      exit;
      }



      }
      }


      when i am submiting value through submit button error is coming










      share|improve this question














      hello everyone i am getting error when sending mail to admin
      email_templates.xml



      <?xml version="1.0"?>                                                  
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-
      instance"xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:
      etc/email_templates.xsd">
      <template id="customemail_email_template" label="Custom Email Template"
      file="custom_template.html" type="html"
      module="Magneto_WholesaleApplication" area="frontend" />
      </config>


      custom_template.html



      <!--@subject Sending email from my custom module @-->

      {{template config_path="design/email/header_template"}}
      <table>
      <tr class="email-intro">
      <td>
      Email: {{var email}}
      </td>
      <td>
      Name: {{var name}}
      </td>
      <td>
      cname: {{var cname}}
      </td>
      <td>
      address: {{var address}}
      </td>
      <td>
      address2: {{var address2}}
      </td>
      <td>
      city: {{var city}}
      </td>
      <td>
      state: {{var state}}
      </td>
      <td>
      zipcode: {{var zipcode}}
      </td>
      <td>
      country_id: {{var country_id}}
      </td>
      <td>
      areacode: {{var areacode}}
      </td>
      <td>
      phonenumber: {{var phonenumber}}
      </td>
      <td>
      website: {{var website}}
      </td>
      <td>
      reseller: {{var reseller}}
      </td>
      <td>
      description: {{var description}}
      </td>
      <td>
      additional: {{var additional}}
      </td>
      <td>
      image: {{var image}}
      </td>
      </tr>
      </table>

      {{template config_path="design/email/footer_template"}}


      Post.php



      <?php
      namespace MagnetoWholesaleApplicationControllerIndex;

      use ZendLogFilterTimestamp;

      class Post extends MagentoFrameworkAppActionAction
      {
      const XML_PATH_EMAIL_RECIPIENT_NAME =
      'trans_email/ident_support/name';
      const XML_PATH_EMAIL_RECIPIENT_EMAIL =
      'trans_email/ident_support/email';

      protected $_inlineTranslation;
      protected $_transportBuilder;
      protected $_scopeConfig;
      protected $_logLoggerInterface;

      public function __construct(
      MagentoFrameworkAppActionContext $context,
      MagentoFrameworkTranslateInlineStateInterface $inlineTranslation,
      MagentoFrameworkMailTemplateTransportBuilder $transportBuilder,
      MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
      PsrLogLoggerInterface $loggerInterface,
      array $data =

      )
      {
      $this->_inlineTranslation = $inlineTranslation;
      $this->_transportBuilder = $transportBuilder;
      $this->_scopeConfig = $scopeConfig;
      $this->_logLoggerInterface = $loggerInterface;
      $this->messageManager = $context->getMessageManager();


      parent::__construct($context);


      }

      public function execute()
      {
      $post = $this->getRequest()->getPost();
      try
      {
      // Send Mail
      $this->_inlineTranslation->suspend();
      $storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;

      $sender = [
      'name' => $post['name'],
      'cname' => $post['cname'],
      'email' => $post['email'],
      'address' => $post['address'],
      'address2' => $post['address2'],
      'city' => $post['city'],
      'state' => $post['state'],
      'zipcode' => $post['zipcode'],
      'country_id' => $post['country_id'],
      'areacode' => $post['areacode'],
      'phonenumber' => $post['phonenumber'],
      'website' => $post['website'],
      'reseller' => $post['reseller'],
      'description' => $post['description'],
      'additional' => $post['additional'],
      'image' => $post['image']

      ];

      $sentToEmail = $this->_scopeConfig -
      >getValue('trans_email/ident_general/email',MagentoStoreModel
      ScopeInterface::SCOPE_STORE);

      $sentToName = $this->_scopeConfig -

      >getValue('trans_email/ident_general/name',MagentoStoreModel
      ScopeInterface::SCOPE_STORE);


      $transport = $this->_transportBuilder
      ->setTemplateIdentifier('custom_template')
      ->setTemplateOptions(
      [
      'area' => 'frontend',
      'store' => MagentoStoreModelStore::DEFAULT_STORE_ID,
      ]
      )
      ->setTemplateVars([
      'name' => $post['name'],
      'cname' => $post['cname'],
      'email' => $post['email'],
      'address' => $post['address'],
      'address2' => $post['address2'],
      'city' => $post['city'],
      'state' => $post['state'],
      'zipcode' => $post['zipcode'],
      'country_id' => $post['country_id'],
      'areacode' => $post['areacode'],
      'phonenumber' => $post['phonenumber'],
      'website' => $post['website'],
      'reseller' => $post['reseller'],
      'description' => $post['description'],
      'additional' => $post['additional'],
      'image' => $post['image']
      ])
      ->setFrom($sender)
      ->addTo($sentToEmail,$sentToName)
      //->addTo('owner@example.com','owner')
      ->getTransport();

      $transport->sendMessage();

      $this->_inlineTranslation->resume();
      $this->messageManager->addSuccess('Email sent successfully');
      $this->_redirect('');

      } catch(Exception $e){
      $this->messageManager->addError($e->getMessage());
      $this->_logLoggerInterface->debug($e->getMessage());
      exit;
      }



      }
      }


      when i am submiting value through submit button error is coming







      magento2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 37 mins ago









      Ashish RamchandaniAshish Ramchandani

      10710




      10710






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262933%2femail-template-custom-template-is-not-defined-in-magento2%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262933%2femail-template-custom-template-is-not-defined-in-magento2%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          What other Star Trek series did the main TNG cast show up in?

          Berlina muro

          Berlina aerponto