2015-09-10 80 views
1

我對MAGENTO很新,我已經構建了一個全新的擴展。 所以我已經創建了表單現在我想發送所有的細節在html中給管理員以及來賓用戶。如何在magento中發送自定義電子郵件

$mail = new Zend_Mail(); 
    $mail->setBodyText($mydata); 
    $mail->setFrom($guestEmail); 
    $mail->addTo('[email protected]', 'Some Recipient'); 
    $mail->setSubject('Test su'); 
    $mail = Mage::getModel('core/email'); 

感謝您的幫助。

回答

1

嘗試這個代碼,我想我已經回答了這個問題: -

<?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('[email protected]'); 
     $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'); 
    } 

} 
相關問題