How can I attach a pdf file to the shipment-email. This wil be the same static file attached to alle shipment emails (gov. required terms).
I have looked into som of the files like dev/lib/mail.php and app/code/cor开发者_如何学JAVAe/Mage/Sales/Model/Email also tried to look at some of the code of the Fooman email attachments extension (wich does not provide the functonality i want), but I'm unsure of how to proceed.
Try something like this.
Mage::getModel('core/email_template')->getMail()->createAttachment(...);
createAttachment(...)
method is in Zend_Mail
class.
in app/code/core/Mage/Core/Model/Email/Template.php in send method find
$mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?=');
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
and replace with
if (isset($variables['attachment'])){
$attfile = file_get_contents($variables['attachment']);
$attfile = fopen($variables['attachment'],'rb');
$att = $mail->createAttachment($attfile);
//$att->type = 'plain/text';
$att->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$att->filename = $variables['attname'];
}
$mail->setSubject('=?utf-8?B?' . base64_encode($this->getProcessedTemplateSubject($variables)) . '?=');
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
精彩评论