Add header and footer in contact form mail template magento

To add a header and footer to a contact form mail template in Magento, you can follow these steps:

Step 1: Create a new template file

In your Magento installation, navigate to the following directory: app/design/frontend/your-theme/email

Create a new file called contactform.xml (if it doesn't already exist).

Step 2: Define the template

In the contactform.xml file, add the following code:

<?xml version="1.0"?>
<layout>
    <contactform>
        <label>Contact Form</label>
        <template>contactform.phtml</template>
    </contactform>
</layout>

This defines a new template called contactform.phtml that will be used for the contact form email.

Step 3: Create the template file

Create a new file called contactform.phtml in the same directory (app/design/frontend/your-theme/email).

Step 4: Add the header and footer

In the contactform.phtml file, add the following code:

<?php
/** @var $this Mage_Core_Email_Template_Abstract */
?>

<!-- Header -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td align="center" style="background-color: #f2f2f2; padding: 20px;">
            <h2>Your Company Name</h2>
            <p>Your Company Address</p>
        </td>
    </tr>
</table>

<!-- Form content goes here -->
<?php echo $this->getFormContent();?>

<!-- Footer -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td align="center" style="padding: 20px;">
            <p>Copyright &copy; <?php echo date('Y');?> Your Company Name</p>
        </td>
    </tr>
</table>

This code adds a header section with a company name and address, followed by the form content (which will be generated by Magento), and finally a footer section with a copyright notice.

Step 5: Update the contact form configuration

In the Magento admin panel, go to System > Configuration > Contacts > Contact Form and update the Email Template field to contactform.

Step 6: Test the contact form

Test the contact form by submitting it and checking the email that is sent. The header and footer should be included in the email template.

That's it! You should now have a contact form email template with a header and footer in Magento.