I'm using Magento's core/email_template model to send an email (as opposed to core/email as I want to add an attachment).

I already have a $html variable which I would like to set as the body. Is there any way I can do so, i.e not have to specify a transaction email ID? Here is the code below:

$mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>1))

The sendTransactional() method just delegates to Mage_Core_Model_Email_Template::send(), so just call the send method directly instead.

public function send($email, $name = null, array $variables = array()) 

EDIT: You can use the Zend_Mail class if you just want to send an email with an attachment. For example:

$mail = new Zend_Mail();
$mail->setFrom("email@example.com","From name");

$mail->setSubject("Mail subject");

$attachment = file_get_contents("path/to/your/attachment.pdf");

$file = new Zend_Mime_Part($attachment);
$file->type        = 'application/pdf';
$file->filename    = $filename;
$file->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$file->encoding = Zend_Mime::ENCODING_BASE64;


Hope this is what you looking for.

  • Thanks for the info. I'm not trying to send a transactional email, I'm simply using that model because I have an attachment. It's failing the isValidForSend method. What do I need to parse through using the $variables variable – Moose Mar 18 '15 at 8:54
  • See my edited answer. – Hans Blaauw Mar 18 '15 at 9:38
  • Thanks for the update. Unfortunately I need to use the built in mailer function due to the fact that I'm on shared hosting. Otherwise regardless of if you set a sender, it is not the permitted sender of the server itself (if you look at the email headers for Received-SPF) – Moose Mar 18 '15 at 9:45
  • Magento uses Zend_Mail aswell, so that shouldn't matter. You can check Mage_Core_Model_Email_Template (so app/code/core/Mage/Core/Model/Email/Template.php) how Magento does it. – Hans Blaauw Mar 18 '15 at 10: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.