Sunday, 23 March 2014

Magento : Add “Subscribe to Newsletter” checkbox on Contact Form

To add "Subscribe to Newsletter" checkbox on Contact form, follow following steps: 

1) Go to contacts/form.phtml file of your selected theme.

2) Place following code in the file as per your requirement :
    <input type="checkbox" name="subscribe_newsletter"><?php echo    
     Mage::helper('contacts')->__(' Subscribe to Newsletter ') ?>

3) Now go to \app\code\local\Mage\Contacts\controllers\IndexController.php file 
    and put following code in postAction() function :

    Note: If you are not able to find Mage/Contacts.... folder in local directory please create new one and refer to the link (

/*Start of code*/


                        $email = $_POST['email'];
                        $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
                        if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
Mage::getSingleton('customer/session') ->addSuccess($this->__('Confirmation request has been sent.'));
Mage::getSingleton('customer/session') ->addSuccess($this->__('Thank you for your newsletter subscription.'));

       /*End of code*/

That’s it and you are done. Hopefully it will help you guys as well.

Thanks!!!!!!!! Enjoy Programming J



  1. Excellent is the only word i can give u for this wonderful blog, keep it up. I will come back again to read some more interesting things on this topic

  2. This will be removed when you upgrade however. I suggest you app\code\local\Mage\Contacts\controllers\IndexController.php and edit that file

    1. I have update the post. Thank you so much for making it correct and more meaningful!!!! :)

  3. i made my controller in app\code\local\Mage\Contacts\controllers\IndexController.php but while running it uses core controller.does not uses controller that i made.but contact form is working fine except for newsletter

  4. Great article! I have had problems with this for a long time
    You run a very good blog. Everything is very understandable. Good job!


Thanks for your valuable comments.