Hello guys i am trying to send an email in magento using custom email templates. But I am getting exception I have installed SMTP Pro Extension.

I am listing code here:-

My config.xml

    <custom_abc_email_template  module="custom_abc">
      <label>Custom Template</label>
      <file>custom_abc_templates/customTemplate.html</file>  // this specifies the path where the custom template is located

code of my controller action

$emailTemplate  = Mage::getModel('core/email_template')->loadDefault('custom_abc_email_template');
$emailTemplate->setSenderName('custom template');
$emailTemplate->send('abc@demomail.com','Forgot Password');

My Template file code

<table cellpadding="0" cellspacing="0" border="0">
        <td class="action-content">
            <h1>Custom Abc,</h1>
            <p><strong>Your new password is:</strong> trolled</p>
            <p>You can change your password at any time by logging into <a href="{{store url="customer/account/"}}">your account</a>.</p>

In exception.log

2016-04-11T10:03:18+00:00 ERR (3): exception 'Exception' with message
'This letter cannot be sent.' in /var/www/html/MMM/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php:40

In aschroder_smtppro.log

2016-04-11T10:03:18+00:00 DEBUG (7): Email is not valid for sending, 
this is a core error that often means there's a problem with your email templates.

setting of email in backend enter image description here

  • $emailTemplate->send('abc@demomail.com','Forgot Password',,$storeId=null); not sure where is problem but try that clear your cache too – Qaisar Satti Apr 11 '16 at 10:46
  • i got one more error now in my system.xml 2016-04-11T10:51:24+00:00 ERR (3): Recoverable Error: Argument 3 passed to Aschroder_SMTPPro_Model_Email_Template::send() must be of the type array, null given, called in /var/www/html/MMM/app/code/local/$ – PRashant PUrohit Apr 11 '16 at 10:53
  • $cus=array(); $emailTemplate->send('abc@demomail.com','Forgot Password',$cus ,$storeId=null); try that – Qaisar Satti Apr 11 '16 at 10:57
  • sir it removed the latest error is still same mail is not going – PRashant PUrohit Apr 11 '16 at 10:59
  • did you the custom email it is going simple email? – Qaisar Satti Apr 11 '16 at 10:59

use below code you were not processing the template..

$emailTemplate  = Mage::getModel('core/email_template')

$emailTemplate->setSenderName('custom template');
$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

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 {
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
  • thank you very much for your help but it is not working can you tell me is my template is correct because in aschroder_smtppro.log m getting Email is not valid for sending, this is a core error that often means there's a problem with your email templates. – PRashant PUrohit Apr 11 '16 at 11:21
  • did you load the email in admin panel and check that? – Qaisar Satti Apr 11 '16 at 11:30
  • it is loading and showing the preview – PRashant PUrohit Apr 11 '16 at 11:33
  • remove this and try with simple text {{store url="customer/account/"}} – Qaisar Satti Apr 11 '16 at 11:37
  • still not working – PRashant PUrohit Apr 11 '16 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.