尝试阻止电子邮件发送工作,但它直接重定向到另一个页面而不发送邮件。 smtp
设置没问题。这段代码工作得很好,但现在什么也没发生。
try{ ..........................................//mail senting
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('catalog/session');
//get customer details
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customer->getId();
$customer->getEmail();
//get general store details
$from_name = Mage::getStoreConfig('trans_email/ident_general/name');
$from_email = Mage::getStoreConfig('trans_email/ident_general/email');
$templateId=7;
$emailTemplate = Mage::getModel('core/email_template')->load($templateId);
//$emailTemplateVariables = array();
//$emailTemplateVariables[‘name′] = "$mh"";
$processedTemplate = $emailTemplate->getProcessedTemplate();
$mail=Mage::getModel('core/email');
$mail->setToName($customer->getId());
$mail->setToEmail($customer->getEmail());
$mail->setBody($processedTemplate);
$mail->setSubject("Upload Conformation ");
// print_r($mail);
//die;
$mail->setFromEmail($from_email);
$mail->setFromName($from_name);
$mail->setType('html');
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
} catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
}
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl().'bank-info/');
} catch (Exception $ex) {
Mage::getSingleton('core/session')->addError($ex->getMessage());
Mage::log($ex->getMessage());
Mage::getSingleton("supplierfrontendproductuploader/session")->setProductData($postData);
if($editMode) {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl() . 'supplierfrontendproductuploader/product/edit/id/'.$postData['product_id']);
} else {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl() . 'supplierfrontendproductuploader/product/create/');
}