I am using Magento I have created one custom form using CMS page.when the form will submit it will send email to respective customer. so i have tried below code to achieve that:



class Shasha_CorporateAccount_IndexController extends Mage_Core_Controller_Front_Action
    public function indexAction()
        if ($data = $this->getRequest()->getPost())
            //echo '<pre>';print_r($data);die;
            $msg_html=  "<table>";
                $msg_html.= "<tr><td>Name</td><td>".$_POST['first_name']." ".$_POST['last_name']."</td></tr>";
                $msg_html.= "<tr><td>Email</td><td>".$_POST['email']."</td></tr>";
                $msg_html.= "<tr><td>Phone</td><td>".$_POST['phone']."</td></tr>";
                $msg_html.= "<tr><td>Company</td><td>".$_POST['company']."</td></tr>";
                ///$msg_html.=  "<tr><td colspan='2'>Note<br>".$_POST['comment']."</td></tr>";
                $msg_html.= "</table>"; 

                $to_email = "shasha@gmail.com";
                $to_name  = "Shasha";
                $subject  = 'Corporate Account Request';
                $Body     = $msg_html;
                $sender_email = $_POST['email'];
                $sender_name = $_POST['first_name'];

                //Sending E-Mail to Customers.
                $mail1 = Mage::getModel('core/email')
                ->setSubject('Subject :'.$subject)
                //Confimation E-Mail Send

                catch(Exception $error)


                $message = $this->__('Thank you for the request, Will get back to you asap.');
            } catch (Exception $e) {
                $message = $this->__('Error to send request.');




if i put this code

   die(Email is sent successfully);

in this response i also get Email is sent successfully but unfortunately customer is not getting any email.

I am unable to find out the correct solution.

Please if anyone can help me on this.

Thanks in advance...!!!


I would suggest check contact us or newsletter emails are working if yes then it might be an issue with your code.

Are you getting any exception error or any logs? If yes then you should fix the error and try again.

Compare your code with the below websites.



Hope this will help you.

  • i have used the exact same code which is mentioned in above urls. also i have check after execute this code there is no exception in logs. – Balwant Singh Sep 26 '19 at 18:57
  • @BalwantSingh have you checked contact us email and newsletter email are working fine? – Nits Sep 27 '19 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.