2

I am very new to MAGENTO, I have build a brand new extension. So i have created form now i want to send all details in html to admin as well as guest user.I am using below code for it.

$mail = new Zend_Mail();
$mail->setBodyText($mydata);
$mail->setFrom($guestEmail);
$mail->addTo('test@gmail.com', 'Some Recipient');
$mail->setSubject('Test su');
$mail = Mage::getModel('core/email'); 

Thanks for help.

  • 1
    Can you be more clear. Are you getting an error? Is it not sending? Is email in general working? – Sander Mangel Sep 10 '15 at 11:38
  • i am getting row html – Vikash Rao Sep 10 '15 at 11:40
1

Few days ago i have created a extension for it i am posting code here, hope it will help you.

<?php
class Arunendra_Headerchanger_IndexController extends Mage_Core_Controller_Front_Action{
   public function sendemailAction()
    {
        //Fetch submited params
        $params = $this->getRequest()->getParams();
        $firstName = $this->getRequest()->getParams('First-Name');
        $lastName = $this->getRequest()->getParams('Last-Name');
        $email = $this->getRequest()->getParams('Email');
        $fullName = $firstName.' '. $lastName;

        $result = array_filter($params, 'strlen' );
        $str = '<table><tr><th>Field:</th><th>Value:</th></tr>';
        foreach($result as $key => $value){
        $str .='<tr>';
        $str .=  '<td>'.$key.':</td><td>'.$value.'</td>';
        $str .= '</tr>';

        }
        $str .=  '</table>';    
        $mail = Mage::getModel('core/email');
        $mail->setToName('Arunendra');
        $mail->setToEmail('arunendra.gct@gmail.com');
        $mail->setBody($str);
        $mail->setSubject('Pre-Employment Application');
        $mail->setFromEmail($email);
        $mail->setFromName($fullName);
        $mail->setType('html');// You can use 'html' or 'text'
        try {
            $mail->send();
            Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
        }        
        catch(Exception $ex) {
            Mage::getSingleton('core/session')->addError('Unable to send email.');

        }

        //Redirect back to index action of (this) inchoo-simplecontact controller
             $this->_redirect('careerform');
    }

}

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.