Magento – Add New inbox tab in customer the dashboard in magento 2

magento2

I need to create a new tab in customer my dashboard using magento 2 called mymail(inbox). Any email, admin send to customer id then store also in this tab based on Gmail Inbox. Anyone know how to do this?

Best Answer

Add below files into your custom module

Ex:-Namespace:- Mytest Modulename : Myemail;

  1. Create customer_account.xml into Mytest/Myemail/view/frontend/layout

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <referenceBlock name="customer_account_navigation">
                <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-myemail">
                    <arguments>
                        <argument name="path" xsi:type="string">myemail/customer</argument>
                        <argument name="label" xsi:type="string"> MyEmail</argument>
                    </arguments>
                </block>
            </referenceBlock>
        </body>
     </page>
    
  2. Create myemail_customer_index.xml into Mytest/Myemail/view/frontend/layout

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
        <update handle="customer_account"/>
        <body>
            <referenceBlock name="page.main.title">
                <action method="setPageTitle">
                    <argument translate="true" name="title" xsi:type="string">MyEmail</argument>
                </action>
             </referenceBlock>
             <referenceContainer name="content">
                 <block class="Magento\Framework\View\Element\Template" name="my_email" template="Mytest_Myemail::test.phtml">
                 </block>
            </referenceContainer>
        </body>
    </page>
    
  3. Create Index.php into Mytest/Myemail/Controller/Customer

    <?php
    namespace Mytest\Myemail\Controller\Customer;
    
    class Index extends \Magento\Framework\App\Action\Action {
    
     public function execute() {
    
        $this->_view->loadLayout();
    
        $this->_view->renderLayout();
      }
    
    }
    
  4. Create test.phtml into Mytest/Myemail/view/frontend/templates

    <?php // Add some code ?>
    
  5. Put routes.xml into folder Mytest/Myemail/etc/frontend with the following inside:

    <?xml version="1.0"?> 
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc‌​/routes.xsd">
        <router id="standard"> 
            <route id="myemail" frontName="myemail"> 
                <module name="Mytest_Myemail" /> 
            </route> 
        </router> 
    </config>