Add below files into your custom module
Ex:-Namespace:- Mytest Modulename : Myemail;
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/index</argument> <argument name="label" xsi:type="string"> MyEmail</argument> </arguments> </block> </referenceBlock> </body> </page>
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>
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(); } }
Create test.phtml into Mytest/Myemail/view/frontend/templates
<?php // Add some code ?>
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>