Contact Form in Magento

Contact Form in Magento

As you know, Magento has a built-in contact form that can be used for general contacts. That form isn’t part of any CMS page, you cannot edit some introduction text, you cannot add phone numbers administration, and you cannot see the breadcrumbs. If you wish to edit text in that default contact form, you will need to update front-end files. Luckily, there is an alternative.

Note:You might notice that this is one of our oldest posts. Upon writing we made one error in the code that was never corrected. Now, this post article is updated and we have fully working instructions. Hope this will help.

If you are a developer, editing your contact form HTML is an easy task. You only need to open file:
app/design/frontend/default/[yourtheme]/template/contacts/form.phtml and you will find your way around.

Once there, you will basically edit the layout of this interface.

However, there are cases when you would like to give your client an option to edit some intro text, edit his phone numbers, edit text behind the form, etc. You are probably guessing that it would be nice to be able to embed contact form in some CMS page. No problem.

  • Go to your CMS> Manage Pages interface
  • Once there, input your HTML as you normally would on any other page
  • Once you are happy with HTML part, add this lines:
    <!– CONTACT FORM –>
    {{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}

Important note: When you copy/paste the code, it is important to know that WordPress saves the quotes in some weird way, so you should replate the pasted quotes and reenter them.

You will notice that we added xml attribute form_action=”/contacts/index/post”. With it we set form action, and your contact form will work properly. Here is how it looks like. Notice the breadcrumbs.

Contact Form

I know that this is not some breakthrough article, but I will certanly create contact CMS page on all of my future Magento projects.

Hope this was helpful. In case you need some help regarding Magento Development, we would be happy to help. Our team of experts would love to review your code and offer insights on improving your store. Our Magento Technical Audit is a great way to start – feel free to contact us!

You made it all the way down here so you must have enjoyed this post! You may also like:

How To Connect Google Analytics 4 To Magento 2 Bojan Mareljic
Bojan Mareljic, | 36

How To Connect Google Analytics 4 To Magento 2

Out of the box Form Validation in Magento Petar Sambolek
Petar Sambolek, | 24

Out of the box Form Validation in Magento

Magento form field AJAX validation Branko Ajzele
Branko Ajzele, | 8

Magento form field AJAX validation


  1. Thank you for your well-explained tutorial.
    However, Contact Form 7 shows up in the WP preview, however, the form does not show up on the webpage.
    Thank you!

  2. Hi,
    Its good post. but there is a minor update in your content
    ” Important note: When you copy/paste the code, it is important to know that WordPress saves the quotes in some weird way, so you should replate the pasted quotes and reenter them.”

    Is this WordPress or Magento?

  3. Really helpful.

    is there any way to email all cart product to store admin… just like an inquiry?

  4. The emails are going to the customer and admin, but the admin is not able to reply to the customer.
    The “reply-to” field is filled with the admin email.
    How to change it ??
    Please assist !!

  5. I get a 404 page when the form submits, it takes me to /contacts/index/post

    I’ve added the form as per your example code as well.

  6. How can I manage the redirect after a message is sent?
    By default it redirects to the default and wrong contact page.

  7. For those who find the error /contacts/index/post could not be found, this is because the rendered form html requires an absolute url – if you compare the form action attribute on your CMS page agains the actual contacts page, you will see your CMS action has been rendered as a relative path.

    It’s not ideal, but simply edit this:

    {{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}

    to this:

    {{block type="core/template" name="contactForm" form_action="YOUR_FULL_BASE_URL_HERE/contacts/index/post" template="contacts/form.phtml"}}

    Dirty hack – yes.

  8. {{block type=”core/template” name=”contactForm” form_action=”{{store direct_url=”contacts”}}/index/post” template=”contacts/form.phtml”}}

  9. Didn’t worked for me.
    Error: The requested URL /contacts/index/post was not found on this server.

  10. I’ve problem with Contact Us page template still showing old theme. But I want to replace new theme which is enabled in my other pages. except: Register, Login, About Us, Contact Us, My wishlist & My cart page.

    Please advice me how can i do visible home page temple to given link pages.

    Thanks in advance.


  11. I was unable to getting email BUT after following your steps :-It worked for me.
    Thank You.

  12. I’ve got it working after google it a bit.

    My problem was related to the extension Mandrill which changes contact form functionality.

    I used:
    {{block type=’core/template’ name=’contactForm’ form_action=’/contacts/index/post’ template=’contacts/form.phtml’}}

    In my CMS Page to show the form and fix the contact form with the information of this post.

    Thanks Inchoo team for such a great contribution to the community given in this blog.

  13. Just a quick thanks for this & all the other articles that you have done for the Magento community.
    Best wishes,

  14. I am tried with this way and worked in local but while uploading to live – it is giving me error as Web-form is not active.

    I put as
    {{block type=”webforms/webforms” name=”webforms” template=”webforms/default.phtml”}}

  15. Thank you. I was trying to figure out why the form was nerver posting and your block for the contact us form actually was the only one that had the info.

    {{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}

    This worked 100%.

  16. If you want to have the contact form with in a phtml page then…

    1- add the block to the xml you want for example I wanted to add a request form to the product view so, i went to catalog.xml at the and add:

    2- just add the getChildHtml:

    getChildHtml(‘contactForm’) ?>

    So simple i know but took me 3 coffes like all easy things in magento…

  17. Thanks for this article. It worked for me but after the form is submitted my navigation links have contacts/index inserted between the base URL and the URL Key, presumably because the URL Key is relative. Any idea how fix this?

  18. Thank you works a dream in 1.6.

    I tried to remove the original link from the footer in my local.xml

    <action method="removeLinkByUrl"><url></url></action>

    but this did not work so I have ended up copying the contacts.xml into my app/theme removing the following section.

            <reference name="footer_links">
                <action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled"><label>Contact Us</label><url>contacts</url><title>Contact Us</title><prepare>true</prepare></action>
  19. Bumping…

    Is there anyway to preserve controller in the CMS page? The block is instantiated right and works fina but after the submit from the contacts form it redirects back to home_url/contacts…

    I think what everyone realy needs is to stay(after submit) in the CMS page like home_url/my-cms-page..


  20. Hi I am trying to add that block type to my CMS and it works great for the main website. But does anyone know how to add it to a multi-store set up? if I add that block to my CMS page that is used by more than one of the other “sub”-stores (eg. the form just redirects back to the main store. Any help would be greatly appreciated.

  21. I’ve used this coding, but it does not give a success message stating that the form has been sent.

    Can you help?

  22. Please, edit previous comment:

    reference name=”content”

    block type=”core/template” name=”contactForm” template=”contacts/form.phtml” form_action=”/contacts/index/post”


  23. @Christopher have you tried with some custom code on your category page? you could do an if statement based on the category the client is and show some info or hide it. Don’t think it is the best way but it should work. When the client is on the t-shirt category show t-shirt message and when on the tobacco one show the tobacco message.
    Hope it helps.

  24. how do I edit the post php file. I need to make sure users can not post javascript etc through the form

  25. Thanks.

    I used like this in my CMS PAGE content and it works fine.

    {{block type=”core/template” name=”contactForm” template=”contacts/form.phtml”}}

  26. Dear inchoo team, I like your work, your blog and your tutorials. Keep up the good work! For me your blog is really important and your articles are everything else than ripped off. Some people might think that this is a free support chat, but don’t get confused by that 😉

    Thumbs up! Best from Berlin,


  27. Christopher,

    I’m really sorry, but our developers are extremely busy and didn’t find time to answer a question in the comments on a blog post written last year.

    I hope you understand that although we wrote over 500 tutorials / modules / extensions completely free for the community here, we do have obligation to finish work for our clients and feed our families. I hope you don’t mind.

    Kind regards,

    Marketing Manager, Inchoo

  28. I guess these guys dont respond to inquires or interact with their readers… been back everyday for a month looking for a response on my previous comment on this post any another by a different author yet nothing…. Either that or it is another pointless autoblog with ripped off articles… who knows. Sincerely disappointing though thats for sure.

    1. Dear Christopher,

      I can understand why you might get this impression, but let me try to shed some light for you to understand our environment. For 3 years, we are trying to share knowledge via this site and help community in learning. There are now over 100.000 people who visit this site on monthly basis. However, due this reason, some people feel like sharing knowledge is our obligation. Let me be blunt. It is not. We get cca 5-10 inquiries per day currently to provide free support. Theses inquiries are often sent after someone messed up something.

      Imagine our workday if we would jump from one side to another trying to help everyone. For free. You don’t need to be economy expert to figure out what would happen. Word would be spread and such free-support inquiries would explode. Inchoo couldn’t pay salaries for employees and they would leave. Quite soon, we would be out of business because nobody would stay.

      I am sad you find this blog pointless. It is your opinion and you are entitled to it. However, I can confirm that the articles are not ripped.

      Thank you!

  29. We have .htaccess rules, which adds a trailing slash at the end of the url. If you have that, you have to change the form action to /contacts/index/post/! Otherwise email won’t be sent.

  30. Just worked out forgot to add the var to email template

    Mobile: {{var}}
    Fax: {{var data.fax}}

    What I really need to do is create a completely New form , not connected to contact us form. I made a duplicate of form.phtml called request.phtml but don’t it is still associated to contact us email template , is it possible to associate away from contact us email template? And how?

  31. I am trying to add 2 extra input fields (Mobile & Fax) by editing form.phtml, they appear when viewing & submitting the form but not in the email?

    <label for="Mobile"><?php echo Mage::helper('contacts')->__('Mobile') ?></label>
    <div class="input-box">
    <input name="mobile" id="mobile" title="<?php echo Mage::helper('contacts')->__('Mobile') ?>" value="" class="input-text" type="text" />

    Have I missed something out?

  32. this is a bit off topic but in previous comments on this thread you mention some altering of the

    <div id="messages_product_view">

    I been looking all over for some help with this and even though its a bit off topic im hoping you can help me out. Heres a copy and paste of the comment i left on another article on this site but by a different author and the article was a bit old so i wasnt sure if i would hear back from him or if he is active on here still.
    I want to display a notice at the top of certain product pages with additional information regarding what they should select and why. For instance you have lets say a tshirt shop and five of the shirts comes in 4 different materials and you want to display a notice at the top of those 5 product pages that tells you the benefit of choosing one material over the other (this is just example mind you heh) and then you also sell something like hookah tobacco in the same shop which has different levels of nicotine and you want to describe how the different levels of nicotine compare to a regular cigarette or something in that notice box is there a way this can be acheived with your guide?

  33. After submitting the form I’m getting a 404. I think this might be related to the fact that I enabled this option: System – Configuration – General – Web – URL Options – Add storecode to URL’s. The storecode is not added after submitting this form. Do you have any solution for this?

  34. I got it working, here’s my code….

    <div id="messages_product_view">
    <?php Mage::app()->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('customer/session')->getMessages(true)); ?>
    <?php echo Mage::app()->getLayout()->getMessagesBlock()->getGroupedHtml(); ?> 
  35. Thank you for these instructions, they have really saved me time.

    I have done this in a static block which is placed on a product page that only displays the static block. I changed the code indexcontrol.php so that the contact form redirects back to the correct page. The only issue I have is that the success or failure messages are not being displayed.
    I’ve left this line of code in the phtml file:

    <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>

    and the div tag ends up being empty. If I have it going back to the default contact page, the success msg fails. Any ideas on what needs to change? The controller file or the phtml file?

  36. Thanks for your very clear instructions. Can you tell me how I would install a newsletter subscription form into a CMS page? I assume there must be an easy way. Thanks!

  37. I’m trying to have a second “contact” form in addition to the default contact form that Magento supplies. I successfully created this second form by duplicating/editing my form.phtml file and including it onto a CMS page using the code that you’ve supplied in this post.

    This becomes problematic in regard to the Email Template that is used when the contact forms are submitted.

    Is there any way that my second contact form can be assigned a different Email Template programmatically through either the .phtml file or on the CMS page?

    I understand that I can set the default contact form’s Email Template in System –> Configuration, but I trying to change the Email Template that is used for my second “contact form.”

  38. It is very useful but i dont know where the contact form is get to know that.what is the indication for confirmation .

  39. I’m trying to implement it and these are my steps so far, i’ve run into a few problems so if anyone could help it would be appreciated.

    1. Copy /app/design/frontend/base/default/template/contacts/ form.phtml to:


    2. Add this code to CMS page:

    {{block type=’core/template’ name=’contactForm’ form_action=”/contacts/index/post” template=’contacts/new_folder/form.phtml’}}

    This will submit the data, but there are some problems:

    – User is returned to default Magento ‘Contact’ page and not the page they submitted the form on.

    – The data is received in the format used in the usual ‘Contact’ form (ie same ‘Subject’ and return and reply email address).

    – The input from the custom fields is not included in the data delivered to the email address.


    1. How to make the return page either the page that the form was submitted on or the home page?

    2. How to customise the subject title, from and reply address in the email?

    3. How to have the custom field input also delivered in the email?

  40. Hello,

    Could someone please post a method for adding a new form to a cms page?

    Is it just as easy as copying the ‘contacts’ folder to your own template and then referencing that in the cms page?


    PS i wasn’t sure if forms had to have different id’s etc?

  41. Does work for me, i enter:

    {{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}

    In the CMS – Manage Pages and nothing….?

  42. putting the contact us form in the cms page is a bit complicated since the controller can’t identify what the current form of action is and that’s why the form action has no value at all but this only works fine in other versions of magento but others may cause some problems.
    Instead of doing that, in your menu put this url as the link ‘index.php/contacts/index/’ to the contact us form. If you are using 2 or 3 columns page then just edit the layout xml for contacts default/layout/contacts.xml then replace the 1column to 2columns or 3 columns.phtml (whichever you like to use). You can edit the .phtml of the contact form in default/template/contacts/form.phtml..

    this works very well for me (i think this works to all magento versions) and moreover you don’t have to get concern about the error messages. by the way the error messages will come up if you are working in your localhost, or you didn’t setup the contacts in the backend configuration.

    Hope this will help.

  43. Hi
    I haven’t yet got this working but the real issue is, how do I get the contacts page to adopt the new template I just installed?

    Thanks for your help in advance.


  44. I did the same thing and just made a new page and pasted your code.
    but when I linked it to main nav and clicked on it, it was a blank page.
    No idea, why it dint work..

  45. I entered the code above as described.
    But when i saved the page it did not work.
    When i looked at the html the cms had added lots of unwanted code – i removed the unwanted code and removed the quotes.
    saved the file and now it works!

  46. I am beginner in magento1.3 and want to add new page before all product details with checkbox … it do..plz help it..

  47. When you copy and paste the code above, the quotes will copy funny. You need to replace the quotes you see with freshly-typed double quotes. (Single Quotes will also work).

    Do this, and it will show right up for you.

  48. Someone please tell me How do i get magento’s new templates on my mail ID…. I want every magento templates on my yahoo ID… How can I get it ?

  49. Got it to work on 1.3.1 with single quotes. Double quotes wouldn;t work for some reason.

    {{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}

  50. I too tried the method described above, but like the comments stated here, it didn’t work (v. 1.3.1). My solution around it was to make a static block called ‘contact_static_block’, which I filled with appropriate content (store hours, directions, etc.).

    Then, in order to insert this static block so that it displayed above the form, I edited the following files:

    /layout/contacts.xml (add this between …)


    /template/contacts/form.phtml (add this to the top)
    getChildHtml(‘contact_static_block’) ?>

    You can probably tweak it a bit more to have a little greater control over the positioning of the static block and where it shows up, but this should suffice if you want it at the top, with the form following the static block content.

    Hope this helps!

  51. hi, set up the contact form in a new cms page. it works fine, only the “send” button has no reaction. Where or how can I set this button to send the form?

  52. I have the same problem as john and ltmayonnaise!

    I have created a page called contact-us and inserted the block into the content of that page like so {{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}

    However, when I view the source, the action attribute on my form is blank and when I click submit button the form refreshes, deletes the form data, no messages are displayed and the mail is not sent.

    I went into System/Configuration/General/Contacts and used my own email address to send to, I used custom email 2 as the sender and used a template based on the default template. Contact us is enabled.

    Any one else solved this problem? I am using Magento

  53. I tried. I can’t get it to show. I used this exactly…

    {{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}

    Not sure if I was suppose to change parts of it to match my template. I’m on Magento 1.1.6

  54. The contact us form works for me on some browser while on others does not work when i click the submit button it comes back to the same page no confirmation no error message and does not send an email too

  55. i’ve been struggling it’s been 2 days now, all i wanted to do is just create a copy of the contact us form, in which i want to change the texts then later i want to add some more fields and dropdowns…etc
    i tried every little possible possibility with no success.
    even the last test i’ve done, is just by adding one button to my mainmenu and in the page pointed by that button i added this line
    {{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}
    i also tried

    in its layout
    the form come out well but whenever i click on send it just refreshes the page, deltes everything on it, no message is displayed on top, and the mail isn’t sent.
    hope i was clear enough
    any ideas or tutorials on how can i create a copy of the contact us module, or on how to fix this sending problem ?
    thanks very much in advance

  56. To John and ltmayonnaise,

    Use single quote instead of double quote. like the following:

    {{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}

  57. I have the same problem as John… action is blank and the submit fails. Any easy solution?

  58. Hi there
    does anybody know how to create an entirely new contact form? I want a “request catalogue” form as well as the standard contact form. i have tried replicating it but there are so many files for the contact form it’s ridiculous.

    any help is appreciated!


  59. is it wise to change the core code of Magento ? when you upgrade the Magento, it will be replaced with the new code. I think the better way to add bcc is create a new custom module to handle that based on class Mage_Sendfriend_Model_Sendfriend.

  60. Hi @monocat,

    In the file “app/code/core/Mage/Sendfriend/model/Sendfriend.php” have only one “public function send()” function, and in that function, find “foreach($this->_emails as $key => $email) {” this line, and then add my code below the foreach statement.

    It works for me!

  61. @Prashant

    Thanks for the input. But where exactly do I insert the codes. There are two public function codes and I tried in both, nothing happened. If you can post sample of the code integrated with magento core file, that would be nice.

  62. Thats the “from address” that gets put into email generated on the server. What is the email address that the contact form information gets sent to on submission?

  63. I checked my theme folders and I don’t have any one called “contact” in “template” subdirectory. It is the default magento theme…

    I can add a home made form but if magento has already ready form, I’d like better use it…

  64. I got it!

    I have edited “public function send()” function in the file “app/code/core/Mage/Sendfriend/model/Sendfriend.php”

    In this file I added the following code line

    //Customization: following line is used to add the bcc, with every mail //which is sent from SendToFriend form.

    below the this line

    foreach($this->_emails as $key => $email) {

    Now whenever anyone send mail (using send to friend form) to there recipient, each mail will also come at the BCC address. Like if user added 5 recipients then you will receive five emails at BCC address.

    It works for me, hope it helps!
    But @Tomislav please check this at your end that this is the right way to do this or we have some other easy way (I don’t think there is any).


  65. Hi Prashant,

    The email sending is triggered in the app/code/core/Mage/Sendfriend/model/Sendfriend.php

    Try to look at the whole app/code/core/Mage/Sendfriend folder and try to find a way to send BCC from there. I didn’t have a chance to play with it yet, but it is a good starting point.

    Keep in mind that actual HTML/Javascript is visible from app/design/frontend/default/[your_theme]/template/sendfriend/send.phtml

    I konow I didn’t give exact solution. If you find it, please share it here. If not, I’ll try to find it when I catch some time. 🙂

  66. Hi,

    Your website is very helpful. Lot of useful magento related stuffs. I am facing a problem with “Send To Friend” module in magento.

    I want when anyone use the “Send to Friend” form to send an email (basically sharing a product) then copy of the same email will be sent at my email id as “BCC”.

    Can you please tell me how to do it? Which file I have to modify?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.