嘗試這個代碼,我想我已經回答了這個問題: -
<?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');
}
}