Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Sending custom emails in Magento Without Template

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.26k
    Comment on it

    *It's simple to send custom emails in magento by using zend mail function with success and error messages see the following code *

    public function postAction()
        {
            $params     = $this->getRequest()->getPost();
            $recipient  = Mage::getStoreConfig('trans_email/ident_general/email');
            //echo $recipient;
            //die();
            if($params)
            {
            $mail = new Zend_Mail();
            $mail->setBodyText(
            "Restaurant Name:".$params['restName'].
            "\nFirst Name:".$params['first_name'].
            "\nLast Name:".$params['last_name'].
            "\nCity:".$params['city'].
            "\nPhone No.:".$params['phone_no'].
            "\nEmail:".$params['email'].
            "\nNeed Help:".$params['help'].
            "Comments".$params['comments']
            );
            $mail->setFrom($params['email'],$params['first_name'].' '.$params['last_name']);
            $mail->addTo($recipient, '');
            $mail->setSubject('New Contact');
            try {
            $mail->send();
            if($mail->send()){
            $message = $this->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.');
            Mage::getSingleton('core/session')->addSuccess($message);
            $this->_redirect('*/*/');}
            else {
            $message = $this->__('Unable to submit your request Please try again later');
            Mage::getSingleton('core/session')->addError($message);
            $this->_redirect('*/*/');
            }
                }
            catch(Exception $ex) {
            $message = $this->__('Unable to submit your request Please try again later');
            Mage::getSingleton('adminhtml/session')->addError($message);
            }
            }
            else {
            $message = $this->__('Unable to submit your request Please try again later');
            Mage::getSingleton('core/session')->addError($message);
            $this->_redirect('*/*/');
            }
    
    
        }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: