Just updating the status/state of the order does not trigger any emails to be sent. The most relevant code is in
app/code/core/Mage/Sales/Model/Order.php
protected function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false)
{
// attempt to set the specified state
if ($shouldProtectState) {
if ($this->isStateProtected($state)) {
Mage::throwException(Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state));
}
}
$this->setData('state', $state);
// add status history
if ($status) {
if ($status === true) {
$status = $this->getConfig()->getStateDefaultStatus($state);
}
$this->setStatus($status);
$history = $this->addStatusHistoryComment($comment, false); // no sense to set $status again
$history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
}
return $this;
}
which does not include any calls to the email sending code. This is usually handled by each individual payment method and can differ substantially. Some will send the order confirmation email, some will send the invoice confirmation email only. If your payment method does not send any emails at all this seems like an oversight during development. For example in
/app/code/core/Mage/Paypal/Model/Express/Checkout.php
you will find $order->sendNewOrderEmail()
to trigger the email sending part.
If all payment methods are not sending any emails check your email sending settings under System > Configuration > Sales Email
if this is not disabled it is time to further check your email configuration and server/Magento error logs for further clues as to why no emails are being sent once you have confirmed what your code is meant to send.
use below code you were not processing the template..
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('custom_abc_email_template');
$emailTemplate->setSenderName('custom template');
$emailTemplate->setSenderEmail('abc@demomail.com');
$emailTemplateVariables = array();
$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
$emailTemplate->send('abc@demomail.com','Forgot Password', $emailTemplateVariables,$storeId=null);
try to send direct email it is working or not
$html="
put your html content here
blah blah
";
$mail = Mage::getModel('core/email');
$mail->setToName('Your Name');
$mail->setToEmail('Youe Email');
$mail->setBody('Mail Text / Mail Content');
$mail->setSubject('Mail Subject');
$mail->setFromEmail('Sender Mail Id');
$mail->setFromName("Msg to Show on Subject");
$mail->setType('html');// YOu can use Html or text as Mail format
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
$this->_redirect('');
}
catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
$this->_redirect('');
}
Best Answer
To send emails from localhost, take these steps: