开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜