Magento 1.9 – Unable to Send Email with Email Template

emailemail-templatesmagento-1.9

  $emailTemplate  = Mage::getModel('core/email_template')
                        ->loadDefault('test_template');                                    


$emailTemplateVariables = array();
 $emailTemplateVariables['test'] = 'Branko';
 $emailTemplateVariables['name'] = 'Ajzele';
 $emailTemplateVariables['reviewurl'] = Mage::getUrl('test/index/review');

echo $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);

$emailTemplate->send('test@gmail.com','John Doe', $emailTemplateVariables);

output echo

It is time to review Branko

Hi Ajzele

Click this Make a Review


error


2015-06-17T10:17:10+00:00 ERR (3): 
exception 'Exception' with message 'This letter cannot be sent.' in /var/www/servicecenters/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php:40

Best Answer

Try this:

So the problem was: !Mage::getStoreConfigFlag('system/smtp/disable') which you can fix up in Admin > System > Configuration > Advanced > System > Mail Sending Settings and change Disable Email Communications to No so the emails are NOT disabled.

Explanation

Look at the /app/code/core/Mage/Core/Model/Email/Template.php.The code throwing this error is:

if (!$this->isValidForSend()) {
    Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
    return false;
}

Look at isValidForSend():

public function isValidForSend()
{
    return !Mage::getStoreConfigFlag('system/smtp/disable')
        && $this->getSenderName()
        && $this->getSenderEmail()
        && $this->getTemplateSubject();
}

More info.

Related Topic