在magento中发送消息,实例代码如下,含有失败和成功的方法,当做新的模块扩展的时候,在一些提交操作的成功和失败的判断的时候,可以使用下面代码进行判断是否成功和失败!
try {
$mail->send();
$message = $this->__('You have Register Successfully');
Mage::getSingleton('core/session')->addSuccess($message);
$this->_redirect('sendemail/index/wholesale');
}
catch(Exception $ex) {
// I assume you have your custom module.
// If not, you may keep 'customer' instead of 'yourmodule'.
Mage::getSingleton('core/session')
->addError(Mage::helper('yourmodule')
->__('Unable to send email.'));
$this->_redirect('sendemail/index/wholesale');
}