Looking to change the email system to allow for adding attachments.

Due to the nature of the attachment (dynamically generated PDF based on a variety of things, from customers/orders/3rd party) I would like to attach the PDF in this function:


in this file:


The changes to the email system in recent versions make finding info online extremely difficult.

It looks as though I should be creating the Zend attachment function in here:


However, it looks as though the email queue system will ignore that.

This seems like it should be a quick and easy task, but I'm absolutely stumped at this point.

  • magento.stackexchange.com/questions/9652/…
    – Haim
    Commented Oct 31, 2018 at 17:06
  • @Haim thank you, but I don't see how that will work, as it requires a new extension and also much of that code looks to be for previous versions of Magento (which used a very different email process) Commented Oct 31, 2018 at 17:25

1 Answer 1


Not great, but I've got a workaround for now.

I've added the Zend file attachment stuff in this file,


inside the send($email, $name = null, array $variables = array()) function.

$filename = $variables['filename']; 
$content = file_get_contents("/var/www/webroot/".$filename); 
//some additional work is done here to verify the file is legitimate/safe/etc.
$attachment = new Zend_Mime_Part($content);
$attachment->type = 'application/pdf';
$attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Zend_Mime::ENCODING_BASE64;
$attachment->filename = $filename;

This allows me to pass the file name from this file: /app/code/local/Mage/Sales/Model/Order.php

Inside queueNewOrderEmail($forceMode = false)

                  'order'        => $this,
                  'billing'      => $this->getBillingAddress(),
                  'payment_html' => $paymentBlockHtml,
                  'customMessage' => $message,
                  'filename' => $filename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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