Magento - Is it possible to attach a file to a transactional email?
I need to attach a file to a transactional email. Basically I have a cron job that generates a report and needs to it email to an admin user.
I was hop开发者_开发技巧ing something like this exists:
Mage::getModel('core/email_template')
->setDesignConfig(array('area'=>'frontend', 'store'=>1))
->createAttachment($file)
->sendTransactional($templateID, $sender, $email, “Admin", $vars);
Thanks in advance for any help.
I found that magento uses the zend_mail frame work. You can call the getMail function to access this framework to add an attachement.
http://framework.zend.com/manual/en/zend.mail.attachments.html
Example
$transactionalEmail = Mage::getModel('core/email_template')->setDesignConfig(array('area'=>'frontend', 'store'=>1));
$transactionalEmail->getMail()->createAttachment($fileContents,'text/csv')->filename = $filename;
$transactionalEmail->sendTransactional($templateID, $sender, $email, "Admin", $vars);
精彩评论